Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dlp/metadata/V2/Dlp.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Dlp/metadata/V2/Storage.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Dlp/samples/V2/DlpServiceClient/cancel_dlp_job.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
* makes a best effort to cancel the DlpJob, but success is not
* guaranteed.
* See
* https://cloud.google.com/sensitive-data-protection/docs/inspecting-storage
* https://docs.cloud.google.com/sensitive-data-protection/docs/inspecting-storage
* and
* https://cloud.google.com/sensitive-data-protection/docs/compute-risk-analysis
* https://docs.cloud.google.com/sensitive-data-protection/docs/compute-risk-analysis
* to learn more.
*
* @param string $formattedName The name of the DlpJob resource to be cancelled. Please see
Expand Down
86 changes: 86 additions & 0 deletions Dlp/samples/V2/DlpServiceClient/create_content_policy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START dlp_v2_generated_DlpService_CreateContentPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\ContentPolicy;
use Google\Cloud\Dlp\V2\ContentPolicy\PolicyAction;
use Google\Cloud\Dlp\V2\ContentPolicy\PolicyRule;
use Google\Cloud\Dlp\V2\CreateContentPolicyRequest;

/**
* Create a ContentPolicy.
*
* @param string $formattedParent Parent resource name.
*
* The format of this value varies depending on the scope of the request
* (project):
*
* + Projects scope:
* `projects/{project_id}/locations/{location_id}`
* Please see {@see DlpServiceClient::locationName()} for help formatting this field.
*/
function create_content_policy_sample(string $formattedParent): void
{
// Create a client.
$dlpServiceClient = new DlpServiceClient();

// Prepare the request message.
$contentPolicyRulesAction = new PolicyAction();
$policyRule = (new PolicyRule())
->setAction($contentPolicyRulesAction);
$contentPolicyRules = [$policyRule,];
$contentPolicy = (new ContentPolicy())
->setRules($contentPolicyRules);
$request = (new CreateContentPolicyRequest())
->setParent($formattedParent)
->setContentPolicy($contentPolicy);

// Call the API and handle any network failures.
try {
/** @var ContentPolicy $response */
$response = $dlpServiceClient->createContentPolicy($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = DlpServiceClient::locationName('[PROJECT]', '[LOCATION]');

create_content_policy_sample($formattedParent);
}
// [END dlp_v2_generated_DlpService_CreateContentPolicy_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
* Creates a DeidentifyTemplate for reusing frequently used configuration
* for de-identifying content, images, and storage.
* See
* https://cloud.google.com/sensitive-data-protection/docs/creating-templates-deid
* https://docs.cloud.google.com/sensitive-data-protection/docs/creating-templates-deid
* to learn more.
*
* @param string $formattedParent Parent resource name.
*
* The format of this value varies depending on the scope of the request
* (project or organization) and whether you have [specified a processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
* location](https://docs.cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:
* `projects/{project_id}/locations/{location_id}`
Expand Down
6 changes: 3 additions & 3 deletions Dlp/samples/V2/DlpServiceClient/create_dlp_job.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
/**
* Creates a new job to inspect storage or calculate risk metrics.
* See
* https://cloud.google.com/sensitive-data-protection/docs/inspecting-storage
* https://docs.cloud.google.com/sensitive-data-protection/docs/inspecting-storage
* and
* https://cloud.google.com/sensitive-data-protection/docs/compute-risk-analysis
* https://docs.cloud.google.com/sensitive-data-protection/docs/compute-risk-analysis
* to learn more.
*
* When no InfoTypes or CustomInfoTypes are specified in inspect jobs, the
Expand All @@ -44,7 +44,7 @@
*
* The format of this value varies depending on whether you have [specified a
* processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
* location](https://docs.cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:
* `projects/{project_id}/locations/{location_id}`
Expand Down
4 changes: 2 additions & 2 deletions Dlp/samples/V2/DlpServiceClient/create_inspect_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
* Creates an InspectTemplate for reusing frequently used configuration
* for inspecting content, images, and storage.
* See
* https://cloud.google.com/sensitive-data-protection/docs/creating-templates
* https://docs.cloud.google.com/sensitive-data-protection/docs/creating-templates
* to learn more.
*
* @param string $formattedParent Parent resource name.
*
* The format of this value varies depending on the scope of the request
* (project or organization) and whether you have [specified a processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
* location](https://docs.cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:
* `projects/{project_id}/locations/{location_id}`
Expand Down
4 changes: 2 additions & 2 deletions Dlp/samples/V2/DlpServiceClient/create_job_trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
* Creates a job trigger to run DLP actions such as scanning storage for
* sensitive information on a set schedule.
* See
* https://cloud.google.com/sensitive-data-protection/docs/creating-job-triggers
* https://docs.cloud.google.com/sensitive-data-protection/docs/creating-job-triggers
* to learn more.
*
* @param string $formattedParent Parent resource name.
*
* The format of this value varies depending on whether you have [specified a
* processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
* location](https://docs.cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:
* `projects/{project_id}/locations/{location_id}`
Expand Down
4 changes: 2 additions & 2 deletions Dlp/samples/V2/DlpServiceClient/create_stored_info_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
/**
* Creates a pre-built stored infoType to be used for inspection.
* See
* https://cloud.google.com/sensitive-data-protection/docs/creating-stored-infotypes
* https://docs.cloud.google.com/sensitive-data-protection/docs/creating-stored-infotypes
* to learn more.
*
* @param string $formattedParent Parent resource name.
*
* The format of this value varies depending on the scope of the request
* (project or organization) and whether you have [specified a processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
* location](https://docs.cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:
* `projects/{project_id}/locations/{location_id}`
Expand Down
2 changes: 1 addition & 1 deletion Dlp/samples/V2/DlpServiceClient/deidentify_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* De-identifies potentially sensitive info from a ContentItem.
* This method has limits on input size and output size.
* See
* https://cloud.google.com/sensitive-data-protection/docs/deidentify-sensitive-data
* https://docs.cloud.google.com/sensitive-data-protection/docs/deidentify-sensitive-data
* to learn more.
*
* When no InfoTypes or CustomInfoTypes are specified in this request, the
Expand Down
70 changes: 70 additions & 0 deletions Dlp/samples/V2/DlpServiceClient/delete_content_policy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START dlp_v2_generated_DlpService_DeleteContentPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\DeleteContentPolicyRequest;

/**
* Delete a ContentPolicy.
*
* @param string $formattedName Resource name of the ContentPolicy to be deleted, in the format:
* `projects/{project}/locations/{location}/contentPolicies/{content_policy}`. Please see
* {@see DlpServiceClient::contentPolicyName()} for help formatting this field.
*/
function delete_content_policy_sample(string $formattedName): void
{
// Create a client.
$dlpServiceClient = new DlpServiceClient();

// Prepare the request message.
$request = (new DeleteContentPolicyRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
$dlpServiceClient->deleteContentPolicy($request);
printf('Call completed successfully.' . PHP_EOL);
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = DlpServiceClient::contentPolicyName('[PROJECT]', '[LOCATION]', '[CONTENT_POLICY]');

delete_content_policy_sample($formattedName);
}
// [END dlp_v2_generated_DlpService_DeleteContentPolicy_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Deletes a DeidentifyTemplate.
* See
* https://cloud.google.com/sensitive-data-protection/docs/creating-templates-deid
* https://docs.cloud.google.com/sensitive-data-protection/docs/creating-templates-deid
* to learn more.
*
* @param string $formattedName Resource name of the organization and deidentify template to be
Expand Down
4 changes: 2 additions & 2 deletions Dlp/samples/V2/DlpServiceClient/delete_dlp_job.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
* no longer interested in the DlpJob result. The job will be canceled if
* possible.
* See
* https://cloud.google.com/sensitive-data-protection/docs/inspecting-storage
* https://docs.cloud.google.com/sensitive-data-protection/docs/inspecting-storage
* and
* https://cloud.google.com/sensitive-data-protection/docs/compute-risk-analysis
* https://docs.cloud.google.com/sensitive-data-protection/docs/compute-risk-analysis
* to learn more.
*
* @param string $formattedName The name of the DlpJob resource to be deleted. Please see
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Deletes an InspectTemplate.
* See
* https://cloud.google.com/sensitive-data-protection/docs/creating-templates
* https://docs.cloud.google.com/sensitive-data-protection/docs/creating-templates
* to learn more.
*
* @param string $formattedName Resource name of the organization and inspectTemplate to be
Expand Down
2 changes: 1 addition & 1 deletion Dlp/samples/V2/DlpServiceClient/delete_job_trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Deletes a job trigger.
* See
* https://cloud.google.com/sensitive-data-protection/docs/creating-job-triggers
* https://docs.cloud.google.com/sensitive-data-protection/docs/creating-job-triggers
* to learn more.
*
* @param string $formattedName Resource name of the project and the triggeredJob, for example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Deletes a stored infoType.
* See
* https://cloud.google.com/sensitive-data-protection/docs/creating-stored-infotypes
* https://docs.cloud.google.com/sensitive-data-protection/docs/creating-stored-infotypes
* to learn more.
*
* @param string $formattedName Resource name of the organization and storedInfoType to be
Expand Down
72 changes: 72 additions & 0 deletions Dlp/samples/V2/DlpServiceClient/get_content_policy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START dlp_v2_generated_DlpService_GetContentPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\ContentPolicy;
use Google\Cloud\Dlp\V2\GetContentPolicyRequest;

/**
* Get a ContentPolicy.
*
* @param string $formattedName Resource name in the format:
* `projects/{project}/locations/{location}/contentPolicies/{content_policy}`. Please see
* {@see DlpServiceClient::contentPolicyName()} for help formatting this field.
*/
function get_content_policy_sample(string $formattedName): void
{
// Create a client.
$dlpServiceClient = new DlpServiceClient();

// Prepare the request message.
$request = (new GetContentPolicyRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var ContentPolicy $response */
$response = $dlpServiceClient->getContentPolicy($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = DlpServiceClient::contentPolicyName('[PROJECT]', '[LOCATION]', '[CONTENT_POLICY]');

get_content_policy_sample($formattedName);
}
// [END dlp_v2_generated_DlpService_GetContentPolicy_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* Gets a DeidentifyTemplate.
* See
* https://cloud.google.com/sensitive-data-protection/docs/creating-templates-deid
* https://docs.cloud.google.com/sensitive-data-protection/docs/creating-templates-deid
* to learn more.
*
* @param string $formattedName Resource name of the organization and deidentify template to be
Expand Down
Loading
Loading