<commit_before># Cloud function that uses the Data loss Prevention API to classify files uploaded to a Cloud storage bucket.

The function is an upgrade to the gcs-dlp-classification example. This version
introduces the use of Pub/Sub as a way for the DLP job to indicate when it has
completed processing a file

Pre-reqs : See the tutorial for the gcs-dlp-classification example

*   In addition to the pre req steps outlined in the tutorial for the
    gcs-dlp-classification example you need to create a Pub/Sub topic and a
    corresponding subscription

The workflow:

*   Create Pub/Sub topic & subscription for notification of DLP job completion
*   Associate the Cloud Function with a quarantine bucket
*   Upload files to the quarantine bucket
*   The cloud function is invoked automatically
*   The Data Loss Prevention API inspects and classifies the data
*   The file is moved to the appropriate bucket

## How to run the example

Deploy the Function replacing `[YOUR_QUARANTINE_BUCKET]` with your bucket name:

`gcloud beta functions deploy dlpQuarantineGCS2 --trigger-bucket
[YOUR_QUARANTINE_BUCKET]`

Change directories to the directory that contains the sample data

Upload the sample files to `[YOUR_QUARANTINE_BUCKET]`

`gsutil -m cp * gs://[YOUR_QUARANTINE_BUCKET]/`

## Refs

https://github.com/googleapis/nodejs-dlp

## License
<commit_msg> update Readme for classification example to include tutorial url<commit_after># Cloud function that uses the Data loss Prevention API to classify files uploaded to a Cloud storage bucket.



Pre-reqs : See the tutorial that accompnaies this example:
https://cloud.google.com/solutions/automating-classification-of-data-uploaded-to-cloud-storage

The workflow:

*   Create Pub/Sub topic & subscription for notification of DLP job completion
*   Associate the Cloud Function with a quarantine bucket
*   Upload files to the quarantine bucket
*   The cloud function is invoked automatically
*   The Data Loss Prevention API inspects and classifies the data
*   The file is moved to the appropriate bucket

## How to run the example

Deploy the Function replacing `[YOUR_QUARANTINE_BUCKET]` with your bucket name:

`gcloud beta functions deploy dlpQuarantineGCS2 --trigger-bucket
[YOUR_QUARANTINE_BUCKET]`

Change directories to the directory that contains the sample data

Upload the sample files to `[YOUR_QUARANTINE_BUCKET]`

`gsutil -m cp * gs://[YOUR_QUARANTINE_BUCKET]/`

## Refs

https://github.com/googleapis/nodejs-dlp

## License

{'fraction_non_alphanumeric': 0.05404323458767014, 'fraction_numerical': 0.0008006405124099279, 'mean_word_length': 4.528761061946903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2960147', 'n_tokens_mistral': 717, 'n_tokens_neox': 691, 'n_words': 310}