יצירת תבניות לבדיקת Sensitive Data Protection

במאמר הזה מוסבר בפירוט איך ליצור תבנית חדשה לבדיקה. כדי לקבל הסבר מהיר על יצירת תבנית חדשה לבדיקה באמצעות מסוףGoogle Cloud , אפשר לעיין במאמר מדריך למתחילים: יצירת תבנית לבדיקת Sensitive Data Protection.

מידע על תבניות

אתם יכולים להשתמש בתבניות כדי ליצור ולשמור מידע על הגדרות לשימוש עם Sensitive Data Protection. תבניות שימושיות להפרדה של פרטי ההגדרה – כמו מה בודקים ואיך מבטלים את הזיהוי – מההטמעה של הבקשות. תבניות מאפשרות לעשות שימוש חוזר בהגדרות ולשמור על עקביות בין משתמשים ומערכי נתונים. בנוסף, בכל פעם שמעדכנים תבנית, היא מתעדכנת בכל טריגר של משימה שמשתמש בה.

‫Sensitive Data Protection תומך בתבניות בדיקה, שמוסברות במאמר הזה, ובתבניות להסרת פרטי הזיהוי, שמוסברות במאמר יצירת תבניות להסרת פרטי הזיהוי ב-Sensitive Data Protection.

מידע על תבניות ב-Sensitive Data Protection זמין במאמר תבניות.

פרטים נוספים על סוגי המידע (infoTypes) שאפשר לציין בתבניות הבדיקה זמינים במאמר חומר עזר בנושא גילוי InfoType.

יצירת תבנית חדשה לבדיקה

המסוף

נכנסים לדף Create template במסוף Google Cloud .

כניסה לדף Create template

הדף יצירת תבנית מכיל את הקטעים הבאים:

הגדרת תבנית

בקטע הגדרת תבנית, מזינים מזהה לתבנית הבדיקה. כך תתייחסו לתבנית כשמריצים משימה, כשיוצרים טריגר למשימה וכו'. אפשר להשתמש באותיות, במספרים ובמקפים. אם רוצים, אפשר גם להזין שם מוצג ידידותי יותר למשתמש, וגם תיאור שיעזור לזכור טוב יותר מה התבנית עושה.

בשדה Resource location, בוחרים את האזור שבו מאוחסנים הנתונים שרוצים לבדוק. תבנית הבדיקה שיוצרים מאוחסנת גם היא באזור הזה. אם רוצים להשתמש בתבנית הבדיקה החדשה בכל אזור, בוחרים באפשרות בכל העולם (כל אזור).

הגדרת זיהוי

לאחר מכן מגדירים מה יזוהה בתוכן באמצעות Sensitive Data Protection על ידי בחירת infoType ואפשרויות אחרות.

גלאי InfoType מוצאים מידע אישי רגיש מסוג מסוים. לדוגמה, גלאי ה-infoType של Sensitive Data Protection US_SOCIAL_SECURITY_NUMBER מוצא מספרי ביטוח לאומי בארה"ב. בנוסף למזהים המובנים של סוגי מידע, אתם יכולים ליצור מזהים משלכם של סוגי מידע בהתאמה אישית.

בקטע InfoTypes, בוחרים את גלאי סוג המידע שמתאים לסוג הנתונים שרוצים לסרוק. לא מומלץ להשאיר את הקטע הזה ריק. במקרה כזה, Sensitive Data Protection יסרוק את הנתונים שלכם באמצעות קבוצת ברירת מחדל של infoTypes, שעשויה לכלול infoTypes שלא נחוצים לכם. מידע נוסף על כל גלאי זמין במאמר בנושא גלאי Infotype.

מידע נוסף על ניהול של סוגי מידע מובנים ובהתאמה אישית מופיע בקטע ניהול סוגי מידע דרך מסוף Google Cloud .

ערכות כללים לבדיקה

ערכות כללים לבדיקה מאפשרות לכם להתאים אישית גלאים מובנים וגלאים מותאמים אישית של infoType באמצעות כללי הקשר. סוגי כללי הבדיקה הם:

כדי להוסיף קבוצת כללים חדשה, קודם צריך לציין גלאי infoType מובנה או מותאם אישית אחד או יותר בקטע InfoTypes. בוחרים את כל הגלאים של סוגי המידע שערכות הכללים משנות (סוגי המידע שמוגדרים כיעד) או משמשים להערכה (סוגי המידע שמוגדרים כהקשר). לאחר מכן, מבצעים את הפעולות הבאות:

  1. לוחצים על הוספת קבוצת כללים.
  2. בשדה בחירת סוגי מידע לטירגוט, בוחרים את סוגי המידע שהכללים ישנו אם התנאים יתקיימו.
  3. לוחצים על הוספת כלל כדי לפתוח תפריט עם אפשרויות, כולל כלל מילת הפעלה, כלל החרגה וכלל התאמה.

כדי ליצור כלל למילת הפעלה, בוחרים באפשרות כלל למילת הפעלה. לאחר מכן, מבצעים את הפעולות הבאות:

  1. בשדה מילת הפעלה מזינים ביטוי רגולרי ש-Sensitive Data Protection מחפש.
  2. בתפריט קרבה למילת ההפעלה, בוחרים אם מילת ההפעלה שהזנתם נמצאת לפני או אחרי סוג המידע שנבחר.
  3. בקטע Hotword distance from infoType (מרחק מילת החיפוש מסוג המידע), מזינים את מספר התווים המשוער בין מילת החיפוש לבין סוג המידע שנבחר.
  4. בקטע התאמה של רמת הסמך, בוחרים אם להקצות להתאמות רמת סבירות קבועה, או להגדיל או להקטין את רמת הסבירות שמוגדרת כברירת מחדל בסכום מסוים.

כדי ליצור כלל החרגה, בוחרים באפשרות כלל החרגה ואת סוג כלל ההחרגה שרוצים ליצור, למשל ביטוי רגולרי. לאחר מכן, מבצעים את הפעולות הבאות:

  1. בהתאם לסוג כלל ההחרגה שבחרתם, מזינים את הביטוי הרגולרי, את הניסוח, את מילת ההפעלה או את סוג המידע של ההקשר שצריך למצוא כדי שהכלל יחול.
  2. בהתאם לסוג כלל ההחרגה שבחרתם, מגדירים את סוג ההתאמה או את סוג ההכלה של התמונה:
    • אם בחרתם כלל החרגה מבוסס-טקסט, בוחרים באחד מסוגי ההתאמה הבאים:
      • התאמה מלאה: הממצא חייב להיות זהה לחלוטין לטקסט או למידע על סוג ההקשר שסיפקתם.
      • התאמה חלקית: מחרוזת משנה בתוצאת החיפוש צריכה להיות זהה לטקסט או למידע על סוג ההקשר שסיפקתם.
      • התאמה הפוכה: הממצא לא יכול להיות זהה לטקסט או למידע על סוג המידע שסיפקתם.
    • אם בחרתם כלל החרגה שמבוסס על תמונה, בוחרים את היחס המרחבי הנדרש בין סוגי המידע של היעד וההקשר. לדוגמה, אם בוחרים באפשרות Encloses (מכיל), הממצא של ההקשר צריך להכיל את ממצא היעד כדי שהכלל יחול.

כדי ליצור כלל התאמה, בוחרים באפשרות כלל התאמה ואת סוג כלל ההתאמה, לדוגמה, התאמה לפי ממצאי תמונות. לאחר מכן, מבצעים את הפעולות הבאות:

  1. בשדה Context infoTypes, בוחרים את הגלאים של סוגי המידע שמספקים הקשר לתוצאת החיפוש. ‫Sensitive Data Protection משתמש ב-infoTypes של הקשר כדי להעריך אם צריך לשנות את infoType היעד.
  2. בשדה Minimum likelihood, בוחרים את רמת הסבירות הנמוכה ביותר שסוגי המידע של ההקשר יכולים לקבל ועדיין להפעיל את כלל ההתאמה. אם ערך הסבירות של כל ממצא של הקשר שזוהה נמוך מהערך הזה, Sensitive Data Protection לא משנה את הסבירות של ממצא היעד.
  3. בממצאים שקשורים לתמונות, בשדה סוג ההכלה של התמונה, בוחרים את היחס המרחבי הנדרש בין סוגי המידע של היעד וההקשר. לדוגמה, אם בוחרים באפשרות Encloses (מכיל), המערכת תחיל את הכלל רק אם הממצא בהקשר מכיל את ממצא היעד.
  4. בשדה סבירות, בוחרים את רמת הסבירות החדשה שרוצים להקצות לממצא היעד.

אפשר להוסיף עוד קבוצות כללים כדי לשפר את תוצאות הסריקה.

סף ביטחון

בכל פעם ש-Sensitive Data Protection מזהה התאמה פוטנציאלית למידע אישי רגיש, הוא מקצה לו ערך הסתברות בסולם שנע בין 'מאוד לא סביר' ל'מאוד סביר'. כשמגדירים כאן ערך סבירות, נותנים ל-Sensitive Data Protection הוראה להתאים רק נתונים שערך הסבירות שלהם שווה לערך הזה או גבוה ממנו.

ערך ברירת המחדל 'אפשרי' מספיק לרוב המטרות. אם אתם מקבלים באופן קבוע התאמות רחבות מדי, כדאי להזיז את פס ההזזה למעלה. אם מקבלים מעט מדי התאמות, מזיזים את פס ההזזה למטה.

כשמסיימים, לוחצים על יצירה כדי ליצור את התבנית. יופיע דף סיכום המידע של התבנית.

כדי לחזור לדף הראשי של Sensitive Data Protection, לוחצים על החץ חזרה במסוף Google Cloud .

C#

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


using Google.Api.Gax.ResourceNames;
using Google.Cloud.Dlp.V2;
using System;

public class InspectTemplateCreate
{
    public static InspectTemplate Create(
        string projectId,
        string templateId,
        string displayName,
        string description,
        Likelihood likelihood,
        int maxFindings,
        bool includeQuote)
    {
        var client = DlpServiceClient.Create();

        var request = new CreateInspectTemplateRequest
        {
            Parent = new LocationName(projectId, "global").ToString(),
            InspectTemplate = new InspectTemplate
            {
                DisplayName = displayName,
                Description = description,
                InspectConfig = new InspectConfig
                {
                    MinLikelihood = likelihood,
                    Limits = new InspectConfig.Types.FindingLimits
                    {
                        MaxFindingsPerRequest = maxFindings
                    },
                    IncludeQuote = includeQuote
                },
            },
            TemplateId = templateId
        };

        var response = client.CreateInspectTemplate(request);

        Console.WriteLine($"Successfully created template {response.Name}.");

        return response;
    }
}

Go

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

import (
	"context"
	"fmt"
	"io"

	dlp "cloud.google.com/go/dlp/apiv2"
	"cloud.google.com/go/dlp/apiv2/dlppb"
)

// createInspectTemplate creates a template with the given configuration.
func createInspectTemplate(w io.Writer, projectID string, templateID, displayName, description string, infoTypeNames []string) error {
	// projectID := "my-project-id"
	// templateID := "my-template"
	// displayName := "My Template"
	// description := "My template description"
	// infoTypeNames := []string{"US_SOCIAL_SECURITY_NUMBER"}

	ctx := context.Background()

	client, err := dlp.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("dlp.NewClient: %w", err)
	}
	defer client.Close()

	// Convert the info type strings to a list of InfoTypes.
	var infoTypes []*dlppb.InfoType
	for _, it := range infoTypeNames {
		infoTypes = append(infoTypes, &dlppb.InfoType{Name: it})
	}

	// Create a configured request.
	req := &dlppb.CreateInspectTemplateRequest{
		Parent:     fmt.Sprintf("projects/%s/locations/global", projectID),
		TemplateId: templateID,
		InspectTemplate: &dlppb.InspectTemplate{
			DisplayName: displayName,
			Description: description,
			InspectConfig: &dlppb.InspectConfig{
				InfoTypes:     infoTypes,
				MinLikelihood: dlppb.Likelihood_POSSIBLE,
				Limits: &dlppb.InspectConfig_FindingLimits{
					MaxFindingsPerRequest: 10,
				},
			},
		},
	}
	// Send the request.
	resp, err := client.CreateInspectTemplate(ctx, req)
	if err != nil {
		return fmt.Errorf("CreateInspectTemplate: %w", err)
	}
	// Print the result.
	fmt.Fprintf(w, "Successfully created inspect template: %v", resp.GetName())
	return nil
}

Java

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


import com.google.cloud.dlp.v2.DlpServiceClient;
import com.google.privacy.dlp.v2.CreateInspectTemplateRequest;
import com.google.privacy.dlp.v2.InfoType;
import com.google.privacy.dlp.v2.InspectConfig;
import com.google.privacy.dlp.v2.InspectTemplate;
import com.google.privacy.dlp.v2.LocationName;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class TemplatesCreate {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    createInspectTemplate(projectId);
  }

  // Creates a template to persist configuration information
  public static void createInspectTemplate(String projectId) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
      // Specify the type of info the inspection will look for.
      // See https://cloud.google.com/dlp/docs/infotypes-reference for complete list of info types
      List<InfoType> infoTypes =
          Stream.of("PHONE_NUMBER", "EMAIL_ADDRESS", "CREDIT_CARD_NUMBER")
              .map(it -> InfoType.newBuilder().setName(it).build())
              .collect(Collectors.toList());

      // Construct the inspection configuration for the template
      InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();

      // Optionally set a display name and a description for the template
      String displayName = "Inspection Config Template";
      String description = "Save configuration for future inspection jobs";

      // Build the template
      InspectTemplate inspectTemplate =
          InspectTemplate.newBuilder()
              .setInspectConfig(inspectConfig)
              .setDisplayName(displayName)
              .setDescription(description)
              .build();

      // Create the request to be sent by the client
      CreateInspectTemplateRequest createInspectTemplateRequest =
          CreateInspectTemplateRequest.newBuilder()
              .setParent(LocationName.of(projectId, "global").toString())
              .setInspectTemplate(inspectTemplate)
              .build();

      // Send the request to the API and process the response
      InspectTemplate response =
          dlpServiceClient.createInspectTemplate(createInspectTemplateRequest);
      System.out.printf("Template created: %s", response.getName());
    }
  }
}

Node.js

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

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

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

// The project ID to run the API call under
// const projectId = 'my-project';

// The minimum likelihood required before returning a match
// const minLikelihood = 'LIKELIHOOD_UNSPECIFIED';

// The maximum number of findings to report per request (0 = server maximum)
// const maxFindings = 0;

// The infoTypes of information to match
// const infoTypes = [{ name: 'PHONE_NUMBER' }, { name: 'EMAIL_ADDRESS' }, { name: 'CREDIT_CARD_NUMBER' }];

// Whether to include the matching string
// const includeQuote = true;

// (Optional) The name of the template to be created.
// const templateId = 'my-template';

// (Optional) The human-readable name to give the template
// const displayName = 'My template';

async function createInspectTemplate() {
  // Construct the inspection configuration for the template
  const inspectConfig = {
    infoTypes: infoTypes,
    minLikelihood: minLikelihood,
    includeQuote: includeQuote,
    limits: {
      maxFindingsPerRequest: maxFindings,
    },
  };

  // Construct template-creation request
  const request = {
    parent: `projects/${projectId}/locations/global`,
    inspectTemplate: {
      inspectConfig: inspectConfig,
      displayName: displayName,
    },
    templateId: templateId,
  };

  const [response] = await dlp.createInspectTemplate(request);
  const templateName = response.name;
  console.log(`Successfully created template ${templateName}.`);
}
createInspectTemplate();

PHP

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\CreateInspectTemplateRequest;
use Google\Cloud\Dlp\V2\InfoType;
use Google\Cloud\Dlp\V2\InspectConfig;
use Google\Cloud\Dlp\V2\InspectConfig\FindingLimits;
use Google\Cloud\Dlp\V2\InspectTemplate;
use Google\Cloud\Dlp\V2\Likelihood;

/**
 * Create a new DLP inspection configuration template.
 *
 * @param string $callingProjectId project ID to run the API call under
 * @param string $templateId       name of the template to be created
 * @param string $displayName      (Optional) The human-readable name to give the template
 * @param string $description      (Optional) A description for the trigger to be created
 * @param int    $maxFindings      (Optional) The maximum number of findings to report per request (0 = server maximum)
 */
function create_inspect_template(
    string $callingProjectId,
    string $templateId,
    string $displayName = '',
    string $description = '',
    int $maxFindings = 0
): void {
    // Instantiate a client.
    $dlp = new DlpServiceClient();

    // ----- Construct inspection config -----
    // The infoTypes of information to match
    $personNameInfoType = (new InfoType())
        ->setName('PERSON_NAME');
    $phoneNumberInfoType = (new InfoType())
        ->setName('PHONE_NUMBER');
    $infoTypes = [$personNameInfoType, $phoneNumberInfoType];

    // Whether to include the matching string in the response
    $includeQuote = true;

    // The minimum likelihood required before returning a match
    $minLikelihood = likelihood::LIKELIHOOD_UNSPECIFIED;

    // Specify finding limits
    $limits = (new FindingLimits())
        ->setMaxFindingsPerRequest($maxFindings);

    // Create the configuration object
    $inspectConfig = (new InspectConfig())
        ->setMinLikelihood($minLikelihood)
        ->setLimits($limits)
        ->setInfoTypes($infoTypes)
        ->setIncludeQuote($includeQuote);

    // Construct inspection template
    $inspectTemplate = (new InspectTemplate())
        ->setInspectConfig($inspectConfig)
        ->setDisplayName($displayName)
        ->setDescription($description);

    // Run request
    $parent = "projects/$callingProjectId/locations/global";
    $createInspectTemplateRequest = (new CreateInspectTemplateRequest())
        ->setParent($parent)
        ->setInspectTemplate($inspectTemplate)
        ->setTemplateId($templateId);
    $template = $dlp->createInspectTemplate($createInspectTemplateRequest);

    // Print results
    printf('Successfully created template %s' . PHP_EOL, $template->getName());
}

Python

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

from typing import List
from typing import Optional

import google.cloud.dlp


def create_inspect_template(
    project: str,
    info_types: List[str],
    template_id: Optional[str] = None,
    display_name: Optional[str] = None,
    min_likelihood: Optional[int] = None,
    max_findings: Optional[int] = None,
    include_quote: Optional[bool] = None,
) -> None:
    """Creates a Data Loss Prevention API inspect template.
    Args:
        project: The Google Cloud project id to use as a parent resource.
        info_types: A list of strings representing info types to look for.
            A full list of info type categories can be fetched from the API.
        template_id: The id of the template. If omitted, an id will be randomly
            generated.
        display_name: The optional display name of the template.
        min_likelihood: A string representing the minimum likelihood threshold
            that constitutes a match. One of: 'LIKELIHOOD_UNSPECIFIED',
            'VERY_UNLIKELY', 'UNLIKELY', 'POSSIBLE', 'LIKELY', 'VERY_LIKELY'.
        max_findings: The maximum number of findings to report; 0 = no maximum.
        include_quote: Boolean for whether to display a quote of the detected
            information in the results.
    Returns:
        None; the response from the API is printed to the terminal.
    """

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

    # Prepare info_types by converting the list of strings into a list of
    # dictionaries (protos are also accepted).
    info_types = [{"name": info_type} for info_type in info_types]

    # Construct the configuration dictionary. Keys which are None may
    # optionally be omitted entirely.
    inspect_config = {
        "info_types": info_types,
        "min_likelihood": min_likelihood,
        "include_quote": include_quote,
        "limits": {"max_findings_per_request": max_findings},
    }

    inspect_template = {
        "inspect_config": inspect_config,
        "display_name": display_name,
    }

    # Convert the project id into a full resource id.
    parent = f"projects/{project}"

    # Call the API.
    response = dlp.create_inspect_template(
        request={
            "parent": parent,
            "inspect_template": inspect_template,
            "template_id": template_id,
        }
    )

    print(f"Successfully created template {response.name}")

REST

תבנית בדיקה היא הגדרת בדיקה שאפשר להשתמש בה שוב, בתוספת מטא-נתונים. במונחי API, האובייקט InspectTemplate הוא למעשה אובייקט InspectConfig שכולל עוד כמה שדות של מטא-נתונים, כמו שם מוצג ותיאור. לכן, כדי ליצור תבנית בדיקה חדשה, השלבים הבסיסיים הם:

  1. מתחילים עם אובייקט InspectConfig.
  2. קוראים לשיטה create או שולחים אליה בקשת POST של המשאב projects.inspectTemplates או organizations.inspectTemplates, כולל בבקשה אובייקט InspectTemplate שמכיל שם מוצג, תיאור ואובייקט InspectConfig.

המינוי ל-InspectTemplate שיוחזר יהיה מוכן לשימוש באופן מיידי. אפשר להפנות אליו בשיחות או בעבודות אחרות באמצעות name. כדי להציג את התבניות הקיימות, קוראים לשיטה *.inspectTemplates.list. כדי לראות תבנית ספציפית, מבצעים קריאה ל-method‏ *.inspectTemplates.get. שימו לב: אפשר ליצור עד 1,000 תבניות.

אם כבר יש לכם ניסיון בבדיקת טקסט, תמונות או תוכן מובנה לזיהוי תוכן רגיש באמצעות Sensitive Data Protection, כבר יצרתם אובייקט InspectConfig. בשלב נוסף הופכים אותו לאובייקט InspectTemplate.

ה-JSON הבא הוא דוגמה למה שאפשר לשלוח למתודה projects.inspectTemplates.create. קובץ ה-JSON הזה יוצר תבנית חדשה עם השם המוצג והתיאור שצוינו, ומחפש התאמות בסוגי המידע PHONE_NUMBER ו-US_TOLLFREE_PHONE_NUMBER. התוצאות כוללות עד 100 התאמות שהסבירות שלהן היא לפחות POSSIBLE, וקטע הקשר לכל אחת מהן. לפרטים נוספים על סוגי המידע (infoTypes) שאפשר לציין בתבניות הבדיקה, אפשר לעיין בחומר העזר בנושא גילוי InfoType.

קלט JSON:

POST https://dlp.googleapis.com/v2/projects/[PROJECT_ID]/inspectTemplates?key={YOUR_API_KEY}

{
  "inspectTemplate":{
    "displayName":"Phone number inspection",
    "description":"Scans for phone numbers",
    "inspectConfig":{
      "infoTypes":[
        {
          "name":"PHONE_NUMBER"
        },
        {
          "name":"US_TOLLFREE_PHONE_NUMBER"
        }
      ],
      "minLikelihood":"POSSIBLE",
      "limits":{
        "maxFindingsPerRequest":100
      },
      "includeQuote":true
    }
  }
}

פלט JSON:

תגובת ה-JSON אמורה להיראות כך:

{
  "name":"projects/[PROJECT_ID]/inspectTemplates/[JOB_ID]",
  "displayName":"Phone number inspection",
  "description":"Scans for phone numbers",
  "createTime":"2018-11-30T07:26:28.164136Z",
  "updateTime":"2018-11-30T07:26:28.164136Z",
  "inspectConfig":{
    "infoTypes":[
      {
        "name":"PHONE_NUMBER"
      },
      {
        "name":"US_TOLLFREE_PHONE_NUMBER"
      }
    ],
    "minLikelihood":"POSSIBLE",
    "limits":{
      "maxFindingsPerRequest":100
    },
    "includeQuote":true
  }
}

כדי להתנסות בזה במהירות, אפשר להשתמש ב-APIs Explorer שמוטמע בהמשך. מידע כללי על שימוש ב-JSON כדי לשלוח בקשות ל-DLP API זמין במדריך לתחילת העבודה עם JSON.

שימוש בתבניות של בדיקות

אחרי שיוצרים תבנית חדשה לבדיקה, אפשר להשתמש בה כשיוצרים משימת בדיקה חדשה או טריגר חדש למשימה. בכל פעם שמעדכנים את התבנית, היא מתעדכנת בכל טריגר של משימה שמשתמש בה. למידע נוסף, כולל דוגמאות קוד, אפשר לעיין במאמרים הבאים:

המסוף

כדי להתחיל במהירות להשתמש בתבנית החדשה, פועלים לפי ההוראות שבמדריך למתחילים ליצירת תבנית לבדיקת Sensitive Data Protection, עם השינוי הבא:

  • בקטע Configure detection (הגדרת זיהוי) > Templates (תבניות), לוחצים על השדה Template name (שם התבנית) ובוחרים את התבנית שיצרתם.

הוראות מפורטות יותר לסריקת התוכן מופיעות במאמר יצירה ותזמון של משימות בדיקה ל-Sensitive Data Protection, ובמיוחד בקטע הגדרת זיהוי.

REST

אפשר להשתמש במזהה התבנית שציינתם כשיוצרים את התבנית בכל מקום שבו מתקבלת inspectTemplateName, למשל:

  • projects.content.inspect: מוצא מידע אישי רגיש פוטנציאלי בתוכן באמצעות התבנית כהגדרה שלו.
  • projects.content.deidentify: מחפש ומסיר פרטי זיהוי ממידע אישי רגיש פוטנציאלי בתוכן באמצעות התבנית כהגדרה שלו. שימו לב שבשיטה הזו נעשה שימוש גם בתבנית בדיקה וגם בתבנית הסרת פרטים מזהים.
  • projects.dlpJobs.create, באובייקט InspectJobConfig: יוצרת משימת בדיקה שכוללת את התבנית כהגדרה שלה.

רשימת תבניות לבדיקה

כדי להציג רשימה של כל תבניות הבדיקה שנוצרו בפרויקט או בארגון הנוכחיים:

המסוף

  1. נכנסים לדף Configuration של Sensitive Data Protection במסוף Google Cloud .

    מעבר אל Configuration

  2. בוחרים את הפרויקט שמכיל את תבניות הבדיקה.

  3. לוחצים על הכרטיסייה תבניות.

במסוף מוצגת רשימה של כל תבניות הבדיקה של הפרויקט הנוכחי.

C#

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


using Google.Api.Gax.ResourceNames;
using Google.Cloud.Dlp.V2;
using System;
using Google.Api.Gax;

public class InspectTemplateList
{
    public static PagedEnumerable<ListInspectTemplatesResponse, InspectTemplate> List(string projectId)
    {
        var client = DlpServiceClient.Create();

        var response = client.ListInspectTemplates(
            new ListInspectTemplatesRequest
            {
                Parent = new LocationName(projectId, "global").ToString(),
            }
        );

        // Uncomment to list templates
        //PrintTemplates(response);

        return response;
    }

    public static void PrintTemplates(PagedEnumerable<ListInspectTemplatesResponse, InspectTemplate> response)
    {
        foreach (var template in response)
        {
            Console.WriteLine($"Template {template.Name}:");
            Console.WriteLine($"\tDisplay Name: {template.DisplayName}");
            Console.WriteLine($"\tDescription: {template.Description}");
            Console.WriteLine($"\tCreated: {template.CreateTime}");
            Console.WriteLine($"\tUpdated: {template.UpdateTime}");
            Console.WriteLine("Configuration:");
            Console.WriteLine($"\tMin Likelihood: {template.InspectConfig?.MinLikelihood}");
            Console.WriteLine($"\tInclude quotes: {template.InspectConfig?.IncludeQuote}");
            Console.WriteLine($"\tMax findings per request: {template.InspectConfig?.Limits.MaxFindingsPerRequest}");
        }
    }
}

Go

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

import (
	"context"
	"fmt"
	"io"
	"time"

	dlp "cloud.google.com/go/dlp/apiv2"
	"cloud.google.com/go/dlp/apiv2/dlppb"
	"github.com/golang/protobuf/ptypes"
	"google.golang.org/api/iterator"
)

// listInspectTemplates lists the inspect templates in the project.
func listInspectTemplates(w io.Writer, projectID string) error {
	// projectID := "my-project-id"

	ctx := context.Background()

	client, err := dlp.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("dlp.NewClient: %w", err)
	}
	defer client.Close()

	// Create a configured request.
	req := &dlppb.ListInspectTemplatesRequest{
		Parent: fmt.Sprintf("projects/%s/locations/global", projectID),
	}

	// Send the request and iterate over the results.
	it := client.ListInspectTemplates(ctx, req)
	for {
		t, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("Next: %w", err)
		}
		fmt.Fprintf(w, "Inspect template %v\n", t.GetName())
		c, err := ptypes.Timestamp(t.GetCreateTime())
		if err != nil {
			return fmt.Errorf("CreateTime Timestamp: %w", err)
		}
		fmt.Fprintf(w, "  Created: %v\n", c.Format(time.RFC1123))
		u, err := ptypes.Timestamp(t.GetUpdateTime())
		if err != nil {
			return fmt.Errorf("UpdateTime Timestamp: %w", err)
		}
		fmt.Fprintf(w, "  Updated: %v\n", u.Format(time.RFC1123))
		fmt.Fprintf(w, "  Display Name: %q\n", t.GetDisplayName())
		fmt.Fprintf(w, "  Description: %q\n", t.GetDescription())
	}

	return nil
}

Java

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


import com.google.cloud.dlp.v2.DlpServiceClient;
import com.google.cloud.dlp.v2.DlpServiceClient.ListInspectTemplatesPagedResponse;
import com.google.privacy.dlp.v2.InfoType;
import com.google.privacy.dlp.v2.InspectConfig;
import com.google.privacy.dlp.v2.InspectTemplate;
import com.google.privacy.dlp.v2.ListInspectTemplatesRequest;
import com.google.privacy.dlp.v2.LocationName;
import java.io.IOException;

class TemplatesList {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    listInspectTemplates(projectId);
  }

  // Lists all templates associated with a given project
  public static void listInspectTemplates(String projectId) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {

      // Create the request to be sent by the client
      ListInspectTemplatesRequest request =
          ListInspectTemplatesRequest.newBuilder()
              .setParent(LocationName.of(projectId, "global").toString())
              .setPageSize(1)
              .build();

      // Send the request
      ListInspectTemplatesPagedResponse response = dlpServiceClient.listInspectTemplates(request);

      // Parse through and process the response
      System.out.println("Templates found:");
      for (InspectTemplate template : response.getPage().getResponse().getInspectTemplatesList()) {
        System.out.printf("Template name: %s\n", template.getName());
        if (template.getDisplayName() != null) {
          System.out.printf("\tDisplay name: %s \n", template.getDisplayName());
          System.out.printf("\tCreate time: %s \n", template.getCreateTime());
          System.out.printf("\tUpdate time: %s \n", template.getUpdateTime());

          // print inspection config
          InspectConfig inspectConfig = template.getInspectConfig();
          for (InfoType infoType : inspectConfig.getInfoTypesList()) {
            System.out.printf("\tInfoType: %s\n", infoType.getName());
          }
          System.out.printf("\tMin likelihood: %s\n", inspectConfig.getMinLikelihood());
          System.out.printf("\tLimits: %s\n", inspectConfig.getLimits().getMaxFindingsPerRequest());
        }
      }
    }
  }
}

Node.js

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

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

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

// The project ID to run the API call under
// const projectId = 'my-project';

// Helper function to pretty-print dates
const formatDate = date => {
  const msSinceEpoch = parseInt(date.seconds, 10) * 1000;
  return new Date(msSinceEpoch).toLocaleString('en-US');
};

async function listInspectTemplates() {
  // Construct template-listing request
  const request = {
    parent: `projects/${projectId}/locations/global`,
  };

  // Run template-deletion request
  const [templates] = await dlp.listInspectTemplates(request);

  templates.forEach(template => {
    console.log(`Template ${template.name}`);
    if (template.displayName) {
      console.log(`  Display name: ${template.displayName}`);
    }

    console.log(`  Created: ${formatDate(template.createTime)}`);
    console.log(`  Updated: ${formatDate(template.updateTime)}`);

    const inspectConfig = template.inspectConfig;
    const infoTypes = inspectConfig.infoTypes.map(x => x.name);
    console.log('  InfoTypes:', infoTypes.join(' '));
    console.log('  Minimum likelihood:', inspectConfig.minLikelihood);
    console.log('  Include quotes:', inspectConfig.includeQuote);

    const limits = inspectConfig.limits;
    console.log('  Max findings per request:', limits.maxFindingsPerRequest);
  });
}

listInspectTemplates();

PHP

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\ListInspectTemplatesRequest;

/**
 * List DLP inspection configuration templates.
 *
 * @param string $callingProjectId  The project ID to run the API call under
 */
function list_inspect_templates(string $callingProjectId): void
{
    // Instantiate a client.
    $dlp = new DlpServiceClient();

    $parent = "projects/$callingProjectId/locations/global";

    // Run request
    $listInspectTemplatesRequest = (new ListInspectTemplatesRequest())
        ->setParent($parent);
    $response = $dlp->listInspectTemplates($listInspectTemplatesRequest);

    // Print results
    $templates = $response->iterateAllElements();

    foreach ($templates as $template) {
        printf('Template %s' . PHP_EOL, $template->getName());
        printf('  Created: %s' . PHP_EOL, $template->getCreateTime()->getSeconds());
        printf('  Updated: %s' . PHP_EOL, $template->getUpdateTime()->getSeconds());
        printf('  Display Name: %s' . PHP_EOL, $template->getDisplayName());
        printf('  Description: %s' . PHP_EOL, $template->getDescription());

        $inspectConfig = $template->getInspectConfig();
        if ($inspectConfig === null) {
            print('  No inspect config.' . PHP_EOL);
        } else {
            printf('  Minimum likelihood: %s' . PHP_EOL, $inspectConfig->getMinLikelihood());
            printf('  Include quotes: %s' . PHP_EOL, $inspectConfig->getIncludeQuote());
            $limits = $inspectConfig->getLimits();
            printf('  Max findings per request: %s' . PHP_EOL, $limits->getMaxFindingsPerRequest());
        }
    }
}

Python

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

import google.cloud.dlp


def list_inspect_templates(project: str) -> None:
    """Lists all Data Loss Prevention API inspect templates.
    Args:
        project: The Google Cloud project id to use as a parent resource.
    Returns:
        None; the response from the API is printed to the terminal.
    """

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

    # Convert the project id into a full resource id.
    parent = f"projects/{project}"

    # Call the API.
    response = dlp.list_inspect_templates(request={"parent": parent})

    for template in response:
        print(f"Template {template.name}:")
        if template.display_name:
            print(f"  Display Name: {template.display_name}")
        print(f"  Created: {template.create_time}")
        print(f"  Updated: {template.update_time}")

        config = template.inspect_config
        print(
            "  InfoTypes: {}".format(", ".join([it.name for it in config.info_types]))
        )
        print(f"  Minimum likelihood: {config.min_likelihood}")
        print(f"  Include quotes: {config.include_quote}")
        print(
            "  Max findings per request: {}".format(
                config.limits.max_findings_per_request
            )
        )

REST

משתמשים באחת מהשיטות של *.*.list:

העתקת תבנית בדיקה לאזור global

  1. נכנסים לדף Configuration של Sensitive Data Protection במסוף Google Cloud .

    מעבר אל Configuration

  2. בסרגל הכלים, לוחצים על רשימת הפרויקטים ובוחרים את הפרויקט שמכיל את תבנית הבדיקה שרוצים להשתמש בה.

  3. לוחצים על הכרטיסייה תבניות ואז על כרטיסיית המשנה בדיקה.

  4. לוחצים על המזהה של התבנית שבה רוצים להשתמש.

  5. בדף פרטי תבנית הבדיקה, לוחצים על העתקה.

  6. בדף Create template, ברשימה Resource location, בוחרים באפשרות Global (any region).

  7. לוחצים על יצירה.

התבנית מועתקת לאזור global.

העתקת תבנית בדיקה לפרויקט אחר

  1. נכנסים לדף Configuration של Sensitive Data Protection במסוף Google Cloud .

    מעבר אל Configuration

  2. בסרגל הכלים, לוחצים על רשימת הפרויקטים ובוחרים את הפרויקט שמכיל את תבנית הבדיקה שרוצים להשתמש בה.

  3. לוחצים על הכרטיסייה תבניות ואז על כרטיסיית המשנה בדיקה.

  4. לוחצים על המזהה של התבנית שבה רוצים להשתמש.

  5. בדף פרטי תבנית הבדיקה, לוחצים על העתקה.

  6. בוחרים את הפרויקט שאליו רוצים להעתיק את תבנית הבדיקה.

    הדף יצירת תבנית נטען מחדש בפרויקט שבחרתם.

  7. לוחצים על יצירה.

התבנית נוצרת בפרויקט שבחרתם.

מחיקת תבניות בדיקה

כדי למחוק תבנית בדיקה:

המסוף

  1. נכנסים לדף Configuration של Sensitive Data Protection במסוף Google Cloud .

    מעבר אל Configuration

  2. בוחרים את הפרויקט שמכיל את תבנית הבדיקה שרוצים למחוק.

  3. לוחצים על הכרטיסייה תבניות. במסוף מוצגת רשימה של כל התבניות של הפרויקט הנוכחי.

  4. בעמודה פעולות של התבנית שרוצים למחוק, לוחצים על תפריט הפעולות הנוספות (שמוצג כסמל של שלוש נקודות אנכיות) ואז על מחיקה.

אפשרות אחרת: ברשימת התבניות, לוחצים על שם התבנית שרוצים למחוק. בדף הפרטים של התבנית, לוחצים על מחיקה.

C#

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


using Google.Cloud.Dlp.V2;
using System;

public class InspectTemplateDelete
{
    public static object Delete(string projectId, string templateName)
    {
        var client = DlpServiceClient.Create();

        var request = new DeleteInspectTemplateRequest
        {
            Name = templateName
        };

        client.DeleteInspectTemplate(request);
        Console.WriteLine($"Successfully deleted template {templateName}.");

        return templateName;
    }
}

Go

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

import (
	"context"
	"fmt"
	"io"

	dlp "cloud.google.com/go/dlp/apiv2"
	"cloud.google.com/go/dlp/apiv2/dlppb"
)

// deleteInspectTemplate deletes the given template.
func deleteInspectTemplate(w io.Writer, templateID string) error {
	// projectID := "my-project-id"
	// templateID := "my-template"

	ctx := context.Background()

	client, err := dlp.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("dlp.NewClient: %w", err)
	}
	defer client.Close()

	req := &dlppb.DeleteInspectTemplateRequest{
		Name: templateID,
	}

	if err := client.DeleteInspectTemplate(ctx, req); err != nil {
		return fmt.Errorf("DeleteInspectTemplate: %w", err)
	}
	fmt.Fprintf(w, "Successfully deleted inspect template %v", templateID)
	return nil
}

Java

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


import com.google.cloud.dlp.v2.DlpServiceClient;
import com.google.privacy.dlp.v2.DeleteInspectTemplateRequest;
import java.io.IOException;

class TemplatesDelete {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String templateId = "your-template-id";
    deleteInspectTemplate(projectId, templateId);
  }

  // Delete an existing template
  public static void deleteInspectTemplate(String projectId, String templateId) throws IOException {
    // Construct the template name to be deleted
    String templateName = String.format("projects/%s/inspectTemplates/%s", projectId, templateId);

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {

      // Create delete template request to be sent by the client
      DeleteInspectTemplateRequest request =
          DeleteInspectTemplateRequest.newBuilder().setName(templateName).build();

      // Send the request with the client
      dlpServiceClient.deleteInspectTemplate(request);
      System.out.printf("Deleted template: %s\n", templateName);
    }
  }
}

Node.js

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

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

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

// The project ID to run the API call under
// const projectId = 'my-project';

// The name of the template to delete
// Parent project ID is automatically extracted from this parameter
// const templateName = 'projects/YOUR_PROJECT_ID/inspectTemplates/#####'
async function deleteInspectTemplate() {
  // Construct template-deletion request
  const request = {
    name: templateName,
  };

  // Run template-deletion request
  await dlp.deleteInspectTemplate(request);
  console.log(`Successfully deleted template ${templateName}.`);
}

deleteInspectTemplate();

PHP

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\DeleteInspectTemplateRequest;

/**
 * Delete a DLP inspection configuration template.
 *
 * @param string $callingProjectId  The project ID to run the API call under
 * @param string $templateId        The name of the template to delete
 */
function delete_inspect_template(
    string $callingProjectId,
    string $templateId
): void {
    // Instantiate a client.
    $dlp = new DlpServiceClient();

    // Run template deletion request
    $templateName = "projects/$callingProjectId/locations/global/inspectTemplates/$templateId";
    $deleteInspectTemplateRequest = (new DeleteInspectTemplateRequest())
        ->setName($templateName);
    $dlp->deleteInspectTemplate($deleteInspectTemplateRequest);

    // Print results
    printf('Successfully deleted template %s' . PHP_EOL, $templateName);
}

Python

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

import google.cloud.dlp


def delete_inspect_template(project: str, template_id: str) -> None:
    """Deletes a Data Loss Prevention API template.
    Args:
        project: The id of the Google Cloud project which owns the template.
        template_id: The id of the template to delete.
    Returns:
        None; the response from the API is printed to the terminal.
    """

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

    # Convert the project id into a full resource id.
    parent = f"projects/{project}"

    # Combine the template id with the parent id.
    template_resource = f"{parent}/inspectTemplates/{template_id}"

    # Call the API.
    dlp.delete_inspect_template(request={"name": template_resource})

    print(f"Template {template_resource} successfully deleted.")

REST

משתמשים באחת מהשיטות של *.*.delete:

בכל שיטה של *.*.delete, צריך לכלול את שם המשאב של התבנית שרוצים למחוק.

המאמרים הבאים