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 RPCs for deleting TableDataProfiles #7294

Merged
merged 2 commits into from
May 9, 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.
78 changes: 78 additions & 0 deletions Dlp/samples/V2/DlpServiceClient/create_connection.php
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_CreateConnection_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\Connection;
use Google\Cloud\Dlp\V2\ConnectionState;
use Google\Cloud\Dlp\V2\CreateConnectionRequest;

/**
* Create a Connection to an external data source.
*
* @param string $formattedParent Parent resource name in the format:
* `projects/{project}/locations/{location}`. Please see
* {@see DlpServiceClient::locationName()} for help formatting this field.
* @param int $connectionState The connection's state in its lifecycle.
*/
function create_connection_sample(string $formattedParent, int $connectionState): void
{
// Create a client.
$dlpServiceClient = new DlpServiceClient();

// Prepare the request message.
$connection = (new Connection())
->setState($connectionState);
$request = (new CreateConnectionRequest())
->setParent($formattedParent)
->setConnection($connection);

// Call the API and handle any network failures.
try {
/** @var Connection $response */
$response = $dlpServiceClient->createConnection($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]');
$connectionState = ConnectionState::CONNECTION_STATE_UNSPECIFIED;

create_connection_sample($formattedParent, $connectionState);
}
// [END dlp_v2_generated_DlpService_CreateConnection_sync]
70 changes: 70 additions & 0 deletions Dlp/samples/V2/DlpServiceClient/delete_connection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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_DeleteConnection_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\DeleteConnectionRequest;

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

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

// Call the API and handle any network failures.
try {
$dlpServiceClient->deleteConnection($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::connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]');

delete_connection_sample($formattedName);
}
// [END dlp_v2_generated_DlpService_DeleteConnection_sync]
74 changes: 74 additions & 0 deletions Dlp/samples/V2/DlpServiceClient/delete_table_data_profile.php
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_DeleteTableDataProfile_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\DeleteTableDataProfileRequest;

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

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

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

delete_table_data_profile_sample($formattedName);
}
// [END dlp_v2_generated_DlpService_DeleteTableDataProfile_sync]
72 changes: 72 additions & 0 deletions Dlp/samples/V2/DlpServiceClient/get_connection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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_GetConnection_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\Connection;
use Google\Cloud\Dlp\V2\GetConnectionRequest;

/**
* Get a Connection by name.
*
* @param string $formattedName Resource name in the format:
* `projects/{project}/locations/{location}/connections/{connection}`. Please see
* {@see DlpServiceClient::connectionName()} for help formatting this field.
*/
function get_connection_sample(string $formattedName): void
{
// Create a client.
$dlpServiceClient = new DlpServiceClient();

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

// Call the API and handle any network failures.
try {
/** @var Connection $response */
$response = $dlpServiceClient->getConnection($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::connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]');

get_connection_sample($formattedName);
}
// [END dlp_v2_generated_DlpService_GetConnection_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use Google\Cloud\Dlp\V2\ListColumnDataProfilesRequest;

/**
* Lists data profiles for an organization.
* Lists column data profiles for an organization.
*
* @param string $formattedParent Resource name of the organization or project, for
* example `organizations/433245324/locations/europe` or
Expand Down
77 changes: 77 additions & 0 deletions Dlp/samples/V2/DlpServiceClient/list_connections.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?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_ListConnections_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\Connection;
use Google\Cloud\Dlp\V2\ListConnectionsRequest;

/**
* Lists Connections in a parent.
*
* @param string $formattedParent Parent name, for example:
* `projects/project-id/locations/global`. Please see
* {@see DlpServiceClient::locationName()} for help formatting this field.
*/
function list_connections_sample(string $formattedParent): void
{
// Create a client.
$dlpServiceClient = new DlpServiceClient();

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

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

/** @var Connection $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::locationName('[PROJECT]', '[LOCATION]');

list_connections_sample($formattedParent);
}
// [END dlp_v2_generated_DlpService_ListConnections_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use Google\Cloud\Dlp\V2\ProjectDataProfile;

/**
* Lists data profiles for an organization.
* Lists project data profiles for an organization.
*
* @param string $formattedParent organizations/{org_id}/locations/{loc_id}
* Please see {@see DlpServiceClient::organizationLocationName()} for help formatting this field.
Expand Down
Loading
Loading