pythongoogle-cloud-dlp

Google Cloud DLP regular custom dictionary error "Dictionary has no "cloudStoragePath" field"


In DLP I'm creating a regular custom dictionary detector that points to a dictionary text file stored in Cloud Storage. Below is what I've done to define the custominfotype. I believe it follows the instructions at https://cloud.google.com/dlp/docs/creating-custom-infotypes-dictionary#examples. Yet it errors with "Protocol message Dictionary has no "cloudStoragePath" field." The text file definitely exists in my cloud storage bucket and I have proper credentials. Can you tell me if I have the syntax wrong? Thank you.

custom_info_types = [
    {
        "info_type": {"name": "TAXES"},
        "likelihood": google.cloud.dlp_v2.Likelihood.POSSIBLE,
        "dictionary": {
                            "cloudStoragePath": {
                                "path": "gs://mybucket/myfile.txt"
                            },
                       },
    }
]

Solution

  • Python doesn't use camel casing, but instead uses snake case.

    See

    https://cloud.google.com/dlp/docs/samples/dlp-deidentify-masking#dlp_deidentify_masking-python

    so that should be cloud_storage_path