DLP API . content

Instance Methods

inspect(body, x__xgafv=None)

Find potentially sensitive info in a list of strings.

redact(body, x__xgafv=None)

Redact potentially sensitive info from a list of strings.

Method Details

inspect(body, x__xgafv=None)
Find potentially sensitive info in a list of strings.
This method has limits on input size, processing time, and output size.

Args:
  body: object, The request body. (required)
    The object takes the form of:

{ # Request to search for potentially sensitive info in a list of items.
    "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.
      { # Container structure for the content to inspect.
        "data": "A String", # Content data to inspect or redact.
        "type": "A String", # Type of the content, as defined in Content-Type HTTP header.
            # Supported types are: all "text" types, octet streams, PNG images,
            # JPEG images.
        "value": "A String", # String data to inspect or redact.
      },
    ],
    "inspectConfig": { # Configuration description of the scanning process. # Configuration for the inspector.
        # When used with redactContent only info_types and min_likelihood are currently
        # used.
      "minLikelihood": "A String", # Only return findings equal or above this threshold.
      "includeQuote": True or False, # When true, a contextual quote from the data that triggered a finding is
          # included in the response; see Finding.quote.
      "excludeTypes": True or False, # When true, exclude type information of the findings.
      "infoTypes": [ # Restrict what info_types to look for. The values must correspond to
          # InfoType values returned by ListInfoTypes or found in documentation.
          # Empty info_types runs all enabled detectors.
        { # Type of information detected by the API.
          "name": "A String", # Name of the information type. For built-in info types, this is provided by
              # the API call ListInfoTypes. For user-defined info types, this is
              # provided by the user. All user-defined info types must have unique names,
              # and cannot conflict with built-in info type names.
        },
      ],
      "maxFindings": 42, # Limit the number of findings per content item.
    },
  }

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # Results of inspecting a list of items.
    "results": [ # Each content_item from the request has a result in this list, in the
        # same order as the request.
      { # All the findings for a single scanned item.
        "findingsTruncated": True or False, # If true, then this item might have more findings than were returned,
            # and the findings returned are an arbitrary subset of all findings.
            # The findings list might be truncated because the input items were too
            # large, or because the server reached the maximum amount of resources
            # allowed for a single API call. For best results, divide the input into
            # smaller batches.
        "findings": [ # List of findings for an item.
          { # Container structure describing a single finding within a string or image.
            "quote": "A String", # The specific string that may be potentially sensitive info.
            "likelihood": "A String", # Estimate of how likely it is that the info_type is correct.
            "infoType": { # Type of information detected by the API. # The specific type of info the string might be.
              "name": "A String", # Name of the information type. For built-in info types, this is provided by
                  # the API call ListInfoTypes. For user-defined info types, this is
                  # provided by the user. All user-defined info types must have unique names,
                  # and cannot conflict with built-in info type names.
            },
            "createTime": "A String", # Timestamp when finding was detected.
            "location": { # Specifies the location of a finding within its source item. # Location of the info found.
              "fieldId": { # General identifier of a data field in a storage service. # Field id of the field containing the finding.
                "columnName": "A String", # Column name describing the field.
              },
              "imageBoxes": [ # Location within an image's pixels.
                { # Bounding box encompassing detected text within an image.
                  "width": 42, # Width of the bounding box in pixels.
                  "top": 42, # Top coordinate of the bounding box. (0,0) is upper left.
                  "left": 42, # Left coordinate of the bounding box. (0,0) is upper left.
                  "height": 42, # Height of the bounding box in pixels.
                },
              ],
              "codepointRange": { # Generic half-open interval [start, end) # Character offsets within a content item, included when content type
                  # is a text. Default charset assumed to be UTF-8.
                "start": "A String", # Index of the first character of the range (inclusive).
                "end": "A String", # Index of the last character of the range (exclusive).
              },
              "recordKey": { # Message for a unique key indicating a record that contains a finding. # Key of the finding.
                "datastoreKey": { # Record key for a finding in Cloud Datastore.
                  "entityKey": { # A unique identifier for a Datastore entity. # Datastore entity key.
                      # If a key's partition ID or any of its path kinds or names are
                      # reserved/read-only, the key is reserved/read-only.
                      # A reserved/read-only key is forbidden in certain documented contexts.
                    "path": [ # The entity path.
                        # An entity path consists of one or more elements composed of a kind and a
                        # string or numerical identifier, which identify entities. The first
                        # element identifies a _root entity_, the second element identifies
                        # a _child_ of the root entity, the third element identifies a child of the
                        # second entity, and so forth. The entities identified by all prefixes of
                        # the path are called the element's _ancestors_.
                        #
                        # A path can never be empty, and a path can have at most 100 elements.
                      { # A (kind, ID/name) pair used to construct a key path.
                          #
                          # If either name or ID is set, the element is complete.
                          # If neither is set, the element is incomplete.
                        "kind": "A String", # The kind of the entity.
                            # A kind matching regex `__.*__` is reserved/read-only.
                            # A kind must not contain more than 1500 bytes when UTF-8 encoded.
                            # Cannot be `""`.
                        "name": "A String", # The name of the entity.
                            # A name matching regex `__.*__` is reserved/read-only.
                            # A name must not be more than 1500 bytes when UTF-8 encoded.
                            # Cannot be `""`.
                        "id": "A String", # The auto-allocated ID of the entity.
                            # Never equal to zero. Values less than zero are discouraged and may not
                            # be supported in the future.
                      },
                    ],
                    "partitionId": { # Datastore partition ID. # Entities are partitioned into subsets, currently identified by a project
                        # ID and namespace ID.
                        # Queries are scoped to a single partition.
                        # A partition ID identifies a grouping of entities. The grouping is always
                        # by project and namespace, however the namespace ID may be empty.
                        #
                        # A partition ID contains several dimensions:
                        # project ID and namespace ID.
                      "projectId": "A String", # The ID of the project to which the entities belong.
                      "namespaceId": "A String", # If not empty, the ID of the namespace to which the entities belong.
                    },
                  },
                },
                "cloudStorageKey": { # Record key for a finding in a Cloud Storage file.
                  "startOffset": "A String", # Byte offset of the referenced data in the file.
                  "filePath": "A String", # Path to the file.
                },
              },
              "byteRange": { # Generic half-open interval [start, end) # Zero-based byte offsets within a content item.
                "start": "A String", # Index of the first character of the range (inclusive).
                "end": "A String", # Index of the last character of the range (exclusive).
              },
            },
          },
        ],
      },
    ],
  }
redact(body, x__xgafv=None)
Redact potentially sensitive info from a list of strings.
This method has limits on input size, processing time, and output size.

Args:
  body: object, The request body. (required)
    The object takes the form of:

{ # Request to search for potentially sensitive info in a list of items
      # and replace it with a default or provided content.
    "items": [ # The list of items to inspect. Up to 100 are allowed per request.
      { # Container structure for the content to inspect.
        "data": "A String", # Content data to inspect or redact.
        "type": "A String", # Type of the content, as defined in Content-Type HTTP header.
            # Supported types are: all "text" types, octet streams, PNG images,
            # JPEG images.
        "value": "A String", # String data to inspect or redact.
      },
    ],
    "inspectConfig": { # Configuration description of the scanning process. # Configuration for the inspector.
        # When used with redactContent only info_types and min_likelihood are currently
        # used.
      "minLikelihood": "A String", # Only return findings equal or above this threshold.
      "includeQuote": True or False, # When true, a contextual quote from the data that triggered a finding is
          # included in the response; see Finding.quote.
      "excludeTypes": True or False, # When true, exclude type information of the findings.
      "infoTypes": [ # Restrict what info_types to look for. The values must correspond to
          # InfoType values returned by ListInfoTypes or found in documentation.
          # Empty info_types runs all enabled detectors.
        { # Type of information detected by the API.
          "name": "A String", # Name of the information type. For built-in info types, this is provided by
              # the API call ListInfoTypes. For user-defined info types, this is
              # provided by the user. All user-defined info types must have unique names,
              # and cannot conflict with built-in info type names.
        },
      ],
      "maxFindings": 42, # Limit the number of findings per content item.
    },
    "replaceConfigs": [ # The strings to replace findings with. Must specify at least one.
      {
        "replaceWith": "A String", # Content replacing sensitive information of given type. Max 256 chars.
        "infoType": { # Type of information detected by the API. # Type of information to replace. Only one ReplaceConfig per info_type
            # should be provided. If ReplaceConfig does not have an info_type, the DLP
            # API matches it against all info_types that are found but not specified in
            # another ReplaceConfig.
          "name": "A String", # Name of the information type. For built-in info types, this is provided by
              # the API call ListInfoTypes. For user-defined info types, this is
              # provided by the user. All user-defined info types must have unique names,
              # and cannot conflict with built-in info type names.
        },
      },
    ],
  }

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # Results of redacting a list of items.
    "items": [ # The redacted content.
      { # Container structure for the content to inspect.
        "data": "A String", # Content data to inspect or redact.
        "type": "A String", # Type of the content, as defined in Content-Type HTTP header.
            # Supported types are: all "text" types, octet streams, PNG images,
            # JPEG images.
        "value": "A String", # String data to inspect or redact.
      },
    ],
  }