Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [Dlp] add Cloud Storage discovery support #7521

Merged
merged 2 commits into from
Jul 15, 2024
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
Binary file modified Dlp/metadata/V2/Dlp.php
Binary file not shown.
Binary file modified Dlp/metadata/V2/Storage.php
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
* (project or organization) and whether you have [specified a processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:<br/>
* + Projects scope, location specified:
* `projects/`<var>PROJECT_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Projects scope, no location specified (defaults to global):<br/>
* + Projects scope, no location specified (defaults to global):
* `projects/`<var>PROJECT_ID</var>
* + Organizations scope, location specified:<br/>
* + Organizations scope, location specified:
* `organizations/`<var>ORG_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Organizations scope, no location specified (defaults to global):<br/>
* + Organizations scope, no location specified (defaults to global):
* `organizations/`<var>ORG_ID</var>
*
* The following example `parent` string specifies a parent project with the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
*
* @param string $formattedParent Parent resource name.
*
* The format of this value is as follows:
* The format of this value varies depending on the scope of the request
* (project or organization):
*
* + Projects scope:
* `projects/`<var>PROJECT_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Organizations scope:
* `organizations/`<var>ORG_ID</var>`/locations/`<var>LOCATION_ID</var>
*
* The following example `parent` string specifies a parent project with the
* identifier `example-project`, and specifies the `europe-west3` location
Expand Down
4 changes: 2 additions & 2 deletions Dlp/samples/V2/DlpServiceClient/create_dlp_job.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
* processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:<br/>
* + Projects scope, location specified:
* `projects/`<var>PROJECT_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Projects scope, no location specified (defaults to global):<br/>
* + Projects scope, no location specified (defaults to global):
* `projects/`<var>PROJECT_ID</var>
*
* The following example `parent` string specifies a parent project with the
Expand Down
8 changes: 4 additions & 4 deletions Dlp/samples/V2/DlpServiceClient/create_inspect_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
* (project or organization) and whether you have [specified a processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:<br/>
* + Projects scope, location specified:
* `projects/`<var>PROJECT_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Projects scope, no location specified (defaults to global):<br/>
* + Projects scope, no location specified (defaults to global):
* `projects/`<var>PROJECT_ID</var>
* + Organizations scope, location specified:<br/>
* + Organizations scope, location specified:
* `organizations/`<var>ORG_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Organizations scope, no location specified (defaults to global):<br/>
* + Organizations scope, no location specified (defaults to global):
* `organizations/`<var>ORG_ID</var>
*
* The following example `parent` string specifies a parent project with the
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 @@ -42,9 +42,9 @@
* processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:<br/>
* + Projects scope, location specified:
* `projects/`<var>PROJECT_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Projects scope, no location specified (defaults to global):<br/>
* + Projects scope, no location specified (defaults to global):
* `projects/`<var>PROJECT_ID</var>
*
* The following example `parent` string specifies a parent project with the
Expand Down
8 changes: 4 additions & 4 deletions Dlp/samples/V2/DlpServiceClient/create_stored_info_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
* (project or organization) and whether you have [specified a processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:<br/>
* + Projects scope, location specified:
* `projects/`<var>PROJECT_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Projects scope, no location specified (defaults to global):<br/>
* + Projects scope, no location specified (defaults to global):
* `projects/`<var>PROJECT_ID</var>
* + Organizations scope, location specified:<br/>
* + Organizations scope, location specified:
* `organizations/`<var>ORG_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Organizations scope, no location specified (defaults to global):<br/>
* + Organizations scope, no location specified (defaults to global):
* `organizations/`<var>ORG_ID</var>
*
* The following example `parent` string specifies a parent project with the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/*
* Copyright 2024 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_DeleteFileStoreDataProfile_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\DeleteFileStoreDataProfileRequest;

/**
* Delete a FileStoreDataProfile. Will not prevent the profile from being
* regenerated if the resource is still included in a discovery configuration.
*
* @param string $formattedName Resource name of the file store data profile. Please see
* {@see DlpServiceClient::fileStoreDataProfileName()} for help formatting this field.
*/
function delete_file_store_data_profile_sample(string $formattedName): void
{
// Create a client.
$dlpServiceClient = new DlpServiceClient();

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

// Call the API and handle any network failures.
try {
$dlpServiceClient->deleteFileStoreDataProfile($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::fileStoreDataProfileName(
'[ORGANIZATION]',
'[LOCATION]',
'[FILE_STORE_DATA_PROFILE]'
);

delete_file_store_data_profile_sample($formattedName);
}
// [END dlp_v2_generated_DlpService_DeleteFileStoreDataProfile_sync]
76 changes: 76 additions & 0 deletions Dlp/samples/V2/DlpServiceClient/get_file_store_data_profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/*
* Copyright 2024 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_GetFileStoreDataProfile_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\FileStoreDataProfile;
use Google\Cloud\Dlp\V2\GetFileStoreDataProfileRequest;

/**
* Gets a file store data profile.
*
* @param string $formattedName Resource name, for example
* `organizations/12345/locations/us/fileStoreDataProfiles/53234423`. Please see
* {@see DlpServiceClient::projectDataProfileName()} for help formatting this field.
*/
function get_file_store_data_profile_sample(string $formattedName): void
{
// Create a client.
$dlpServiceClient = new DlpServiceClient();

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

// Call the API and handle any network failures.
try {
/** @var FileStoreDataProfile $response */
$response = $dlpServiceClient->getFileStoreDataProfile($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::projectDataProfileName(
'[ORGANIZATION]',
'[LOCATION]',
'[PROJECT_DATA_PROFILE]'
);

get_file_store_data_profile_sample($formattedName);
}
// [END dlp_v2_generated_DlpService_GetFileStoreDataProfile_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
* (project or organization) and whether you have [specified a processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:<br/>
* + Projects scope, location specified:
* `projects/`<var>PROJECT_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Projects scope, no location specified (defaults to global):<br/>
* + Projects scope, no location specified (defaults to global):
* `projects/`<var>PROJECT_ID</var>
* + Organizations scope, location specified:<br/>
* + Organizations scope, location specified:
* `organizations/`<var>ORG_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Organizations scope, no location specified (defaults to global):<br/>
* + Organizations scope, no location specified (defaults to global):
* `organizations/`<var>ORG_ID</var>
*
* The following example `parent` string specifies a parent project with the
Expand Down
4 changes: 2 additions & 2 deletions Dlp/samples/V2/DlpServiceClient/list_dlp_jobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
* processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:<br/>
* + Projects scope, location specified:
* `projects/`<var>PROJECT_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Projects scope, no location specified (defaults to global):<br/>
* + Projects scope, no location specified (defaults to global):
* `projects/`<var>PROJECT_ID</var>
*
* The following example `parent` string specifies a parent project with the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/*
* Copyright 2024 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_ListFileStoreDataProfiles_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\FileStoreDataProfile;
use Google\Cloud\Dlp\V2\ListFileStoreDataProfilesRequest;

/**
* Lists file store data profiles for an organization.
*
* @param string $formattedParent Resource name of the organization or project, for
* example `organizations/433245324/locations/europe` or
* `projects/project-id/locations/asia`. Please see
* {@see DlpServiceClient::organizationLocationName()} for help formatting this field.
*/
function list_file_store_data_profiles_sample(string $formattedParent): void
{
// Create a client.
$dlpServiceClient = new DlpServiceClient();

// Prepare the request message.
$request = (new ListFileStoreDataProfilesRequest())
->setParent($formattedParent);

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $dlpServiceClient->listFileStoreDataProfiles($request);

/** @var FileStoreDataProfile $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->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::organizationLocationName('[ORGANIZATION]', '[LOCATION]');

list_file_store_data_profiles_sample($formattedParent);
}
// [END dlp_v2_generated_DlpService_ListFileStoreDataProfiles_sync]
8 changes: 4 additions & 4 deletions Dlp/samples/V2/DlpServiceClient/list_inspect_templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
* (project or organization) and whether you have [specified a processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:<br/>
* + Projects scope, location specified:
* `projects/`<var>PROJECT_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Projects scope, no location specified (defaults to global):<br/>
* + Projects scope, no location specified (defaults to global):
* `projects/`<var>PROJECT_ID</var>
* + Organizations scope, location specified:<br/>
* + Organizations scope, location specified:
* `organizations/`<var>ORG_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Organizations scope, no location specified (defaults to global):<br/>
* + Organizations scope, no location specified (defaults to global):
* `organizations/`<var>ORG_ID</var>
*
* The following example `parent` string specifies a parent project with the
Expand Down
4 changes: 2 additions & 2 deletions Dlp/samples/V2/DlpServiceClient/list_job_triggers.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
* processing
* location](https://cloud.google.com/sensitive-data-protection/docs/specifying-location):
*
* + Projects scope, location specified:<br/>
* + Projects scope, location specified:
* `projects/`<var>PROJECT_ID</var>`/locations/`<var>LOCATION_ID</var>
* + Projects scope, no location specified (defaults to global):<br/>
* + Projects scope, no location specified (defaults to global):
* `projects/`<var>PROJECT_ID</var>
*
* The following example `parent` string specifies a parent project with the
Expand Down
Loading
Loading