diff --git a/Dlp/metadata/V2/Dlp.php b/Dlp/metadata/V2/Dlp.php index 20ae8e5572b2..b25541a6106d 100644 Binary files a/Dlp/metadata/V2/Dlp.php and b/Dlp/metadata/V2/Dlp.php differ diff --git a/Dlp/samples/V2/DlpServiceClient/create_connection.php b/Dlp/samples/V2/DlpServiceClient/create_connection.php new file mode 100644 index 000000000000..abbf09650f9a --- /dev/null +++ b/Dlp/samples/V2/DlpServiceClient/create_connection.php @@ -0,0 +1,78 @@ +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] diff --git a/Dlp/samples/V2/DlpServiceClient/delete_connection.php b/Dlp/samples/V2/DlpServiceClient/delete_connection.php new file mode 100644 index 000000000000..13dbad8fcf6d --- /dev/null +++ b/Dlp/samples/V2/DlpServiceClient/delete_connection.php @@ -0,0 +1,70 @@ +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] diff --git a/Dlp/samples/V2/DlpServiceClient/delete_table_data_profile.php b/Dlp/samples/V2/DlpServiceClient/delete_table_data_profile.php new file mode 100644 index 000000000000..05e273d94ca0 --- /dev/null +++ b/Dlp/samples/V2/DlpServiceClient/delete_table_data_profile.php @@ -0,0 +1,74 @@ +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] diff --git a/Dlp/samples/V2/DlpServiceClient/get_connection.php b/Dlp/samples/V2/DlpServiceClient/get_connection.php new file mode 100644 index 000000000000..e5af3e946341 --- /dev/null +++ b/Dlp/samples/V2/DlpServiceClient/get_connection.php @@ -0,0 +1,72 @@ +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] diff --git a/Dlp/samples/V2/DlpServiceClient/list_column_data_profiles.php b/Dlp/samples/V2/DlpServiceClient/list_column_data_profiles.php index e42af50fd299..a285f12d5096 100644 --- a/Dlp/samples/V2/DlpServiceClient/list_column_data_profiles.php +++ b/Dlp/samples/V2/DlpServiceClient/list_column_data_profiles.php @@ -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 diff --git a/Dlp/samples/V2/DlpServiceClient/list_connections.php b/Dlp/samples/V2/DlpServiceClient/list_connections.php new file mode 100644 index 000000000000..31cee6928593 --- /dev/null +++ b/Dlp/samples/V2/DlpServiceClient/list_connections.php @@ -0,0 +1,77 @@ +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] diff --git a/Dlp/samples/V2/DlpServiceClient/list_project_data_profiles.php b/Dlp/samples/V2/DlpServiceClient/list_project_data_profiles.php index fe0be1f3bc16..d5548dedc860 100644 --- a/Dlp/samples/V2/DlpServiceClient/list_project_data_profiles.php +++ b/Dlp/samples/V2/DlpServiceClient/list_project_data_profiles.php @@ -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. diff --git a/Dlp/samples/V2/DlpServiceClient/list_table_data_profiles.php b/Dlp/samples/V2/DlpServiceClient/list_table_data_profiles.php index a26f7fe7e268..256859c421db 100644 --- a/Dlp/samples/V2/DlpServiceClient/list_table_data_profiles.php +++ b/Dlp/samples/V2/DlpServiceClient/list_table_data_profiles.php @@ -30,7 +30,7 @@ use Google\Cloud\Dlp\V2\TableDataProfile; /** - * Lists data profiles for an organization. + * Lists table data profiles for an organization. * * @param string $formattedParent Resource name of the organization or project, for * example `organizations/433245324/locations/europe` or diff --git a/Dlp/samples/V2/DlpServiceClient/search_connections.php b/Dlp/samples/V2/DlpServiceClient/search_connections.php new file mode 100644 index 000000000000..8156bf13200e --- /dev/null +++ b/Dlp/samples/V2/DlpServiceClient/search_connections.php @@ -0,0 +1,77 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $dlpServiceClient->searchConnections($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]'); + + search_connections_sample($formattedParent); +} +// [END dlp_v2_generated_DlpService_SearchConnections_sync] diff --git a/Dlp/samples/V2/DlpServiceClient/update_connection.php b/Dlp/samples/V2/DlpServiceClient/update_connection.php new file mode 100644 index 000000000000..05f37b598201 --- /dev/null +++ b/Dlp/samples/V2/DlpServiceClient/update_connection.php @@ -0,0 +1,78 @@ +setState($connectionState); + $request = (new UpdateConnectionRequest()) + ->setName($formattedName) + ->setConnection($connection); + + // Call the API and handle any network failures. + try { + /** @var Connection $response */ + $response = $dlpServiceClient->updateConnection($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]'); + $connectionState = ConnectionState::CONNECTION_STATE_UNSPECIFIED; + + update_connection_sample($formattedName, $connectionState); +} +// [END dlp_v2_generated_DlpService_UpdateConnection_sync] diff --git a/Dlp/src/V2/AllOtherDatabaseResources.php b/Dlp/src/V2/AllOtherDatabaseResources.php new file mode 100644 index 000000000000..77c9979299d6 --- /dev/null +++ b/Dlp/src/V2/AllOtherDatabaseResources.php @@ -0,0 +1,33 @@ +google.privacy.dlp.v2.AllOtherDatabaseResources + */ +class AllOtherDatabaseResources extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + +} + diff --git a/Dlp/src/V2/Client/DlpServiceClient.php b/Dlp/src/V2/Client/DlpServiceClient.php index bb3285d36325..2e7b307d088b 100644 --- a/Dlp/src/V2/Client/DlpServiceClient.php +++ b/Dlp/src/V2/Client/DlpServiceClient.php @@ -36,6 +36,8 @@ use Google\Cloud\Dlp\V2\ActivateJobTriggerRequest; use Google\Cloud\Dlp\V2\CancelDlpJobRequest; use Google\Cloud\Dlp\V2\ColumnDataProfile; +use Google\Cloud\Dlp\V2\Connection; +use Google\Cloud\Dlp\V2\CreateConnectionRequest; use Google\Cloud\Dlp\V2\CreateDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\CreateDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\CreateDlpJobRequest; @@ -45,16 +47,19 @@ use Google\Cloud\Dlp\V2\DeidentifyContentRequest; use Google\Cloud\Dlp\V2\DeidentifyContentResponse; use Google\Cloud\Dlp\V2\DeidentifyTemplate; +use Google\Cloud\Dlp\V2\DeleteConnectionRequest; use Google\Cloud\Dlp\V2\DeleteDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\DeleteDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\DeleteDlpJobRequest; use Google\Cloud\Dlp\V2\DeleteInspectTemplateRequest; use Google\Cloud\Dlp\V2\DeleteJobTriggerRequest; use Google\Cloud\Dlp\V2\DeleteStoredInfoTypeRequest; +use Google\Cloud\Dlp\V2\DeleteTableDataProfileRequest; use Google\Cloud\Dlp\V2\DiscoveryConfig; use Google\Cloud\Dlp\V2\DlpJob; use Google\Cloud\Dlp\V2\FinishDlpJobRequest; use Google\Cloud\Dlp\V2\GetColumnDataProfileRequest; +use Google\Cloud\Dlp\V2\GetConnectionRequest; use Google\Cloud\Dlp\V2\GetDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\GetDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\GetDlpJobRequest; @@ -71,6 +76,7 @@ use Google\Cloud\Dlp\V2\InspectTemplate; use Google\Cloud\Dlp\V2\JobTrigger; use Google\Cloud\Dlp\V2\ListColumnDataProfilesRequest; +use Google\Cloud\Dlp\V2\ListConnectionsRequest; use Google\Cloud\Dlp\V2\ListDeidentifyTemplatesRequest; use Google\Cloud\Dlp\V2\ListDiscoveryConfigsRequest; use Google\Cloud\Dlp\V2\ListDlpJobsRequest; @@ -86,8 +92,10 @@ use Google\Cloud\Dlp\V2\RedactImageResponse; use Google\Cloud\Dlp\V2\ReidentifyContentRequest; use Google\Cloud\Dlp\V2\ReidentifyContentResponse; +use Google\Cloud\Dlp\V2\SearchConnectionsRequest; use Google\Cloud\Dlp\V2\StoredInfoType; use Google\Cloud\Dlp\V2\TableDataProfile; +use Google\Cloud\Dlp\V2\UpdateConnectionRequest; use Google\Cloud\Dlp\V2\UpdateDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\UpdateDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\UpdateInspectTemplateRequest; @@ -116,6 +124,7 @@ * * @method PromiseInterface activateJobTriggerAsync(ActivateJobTriggerRequest $request, array $optionalArgs = []) * @method PromiseInterface cancelDlpJobAsync(CancelDlpJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConnectionAsync(CreateConnectionRequest $request, array $optionalArgs = []) * @method PromiseInterface createDeidentifyTemplateAsync(CreateDeidentifyTemplateRequest $request, array $optionalArgs = []) * @method PromiseInterface createDiscoveryConfigAsync(CreateDiscoveryConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface createDlpJobAsync(CreateDlpJobRequest $request, array $optionalArgs = []) @@ -123,14 +132,17 @@ * @method PromiseInterface createJobTriggerAsync(CreateJobTriggerRequest $request, array $optionalArgs = []) * @method PromiseInterface createStoredInfoTypeAsync(CreateStoredInfoTypeRequest $request, array $optionalArgs = []) * @method PromiseInterface deidentifyContentAsync(DeidentifyContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConnectionAsync(DeleteConnectionRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteDeidentifyTemplateAsync(DeleteDeidentifyTemplateRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteDiscoveryConfigAsync(DeleteDiscoveryConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteDlpJobAsync(DeleteDlpJobRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteInspectTemplateAsync(DeleteInspectTemplateRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteJobTriggerAsync(DeleteJobTriggerRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteStoredInfoTypeAsync(DeleteStoredInfoTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTableDataProfileAsync(DeleteTableDataProfileRequest $request, array $optionalArgs = []) * @method PromiseInterface finishDlpJobAsync(FinishDlpJobRequest $request, array $optionalArgs = []) * @method PromiseInterface getColumnDataProfileAsync(GetColumnDataProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConnectionAsync(GetConnectionRequest $request, array $optionalArgs = []) * @method PromiseInterface getDeidentifyTemplateAsync(GetDeidentifyTemplateRequest $request, array $optionalArgs = []) * @method PromiseInterface getDiscoveryConfigAsync(GetDiscoveryConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface getDlpJobAsync(GetDlpJobRequest $request, array $optionalArgs = []) @@ -143,6 +155,7 @@ * @method PromiseInterface hybridInspectJobTriggerAsync(HybridInspectJobTriggerRequest $request, array $optionalArgs = []) * @method PromiseInterface inspectContentAsync(InspectContentRequest $request, array $optionalArgs = []) * @method PromiseInterface listColumnDataProfilesAsync(ListColumnDataProfilesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConnectionsAsync(ListConnectionsRequest $request, array $optionalArgs = []) * @method PromiseInterface listDeidentifyTemplatesAsync(ListDeidentifyTemplatesRequest $request, array $optionalArgs = []) * @method PromiseInterface listDiscoveryConfigsAsync(ListDiscoveryConfigsRequest $request, array $optionalArgs = []) * @method PromiseInterface listDlpJobsAsync(ListDlpJobsRequest $request, array $optionalArgs = []) @@ -154,6 +167,8 @@ * @method PromiseInterface listTableDataProfilesAsync(ListTableDataProfilesRequest $request, array $optionalArgs = []) * @method PromiseInterface redactImageAsync(RedactImageRequest $request, array $optionalArgs = []) * @method PromiseInterface reidentifyContentAsync(ReidentifyContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchConnectionsAsync(SearchConnectionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConnectionAsync(UpdateConnectionRequest $request, array $optionalArgs = []) * @method PromiseInterface updateDeidentifyTemplateAsync(UpdateDeidentifyTemplateRequest $request, array $optionalArgs = []) * @method PromiseInterface updateDiscoveryConfigAsync(UpdateDiscoveryConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface updateInspectTemplateAsync(UpdateInspectTemplateRequest $request, array $optionalArgs = []) @@ -227,6 +242,25 @@ public static function columnDataProfileName(string $organization, string $locat ]); } + /** + * Formats a string containing the fully-qualified path to represent a connection + * resource. + * + * @param string $project + * @param string $location + * @param string $connection + * + * @return string The formatted connection resource. + */ + public static function connectionName(string $project, string $location, string $connection): string + { + return self::getPathTemplate('connection')->render([ + 'project' => $project, + 'location' => $location, + 'connection' => $connection, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a * deidentify_template resource. @@ -840,6 +874,7 @@ public static function tableDataProfileName(string $organization, string $locati * The following name formats are supported: * Template: Pattern * - columnDataProfile: organizations/{organization}/locations/{location}/columnDataProfiles/{column_data_profile} + * - connection: projects/{project}/locations/{location}/connections/{connection} * - deidentifyTemplate: organizations/{organization}/deidentifyTemplates/{deidentify_template} * - discoveryConfig: projects/{project}/locations/{location}/discoveryConfigs/{discovery_config} * - dlpJob: projects/{project}/dlpJobs/{dlp_job} @@ -1022,6 +1057,32 @@ public function cancelDlpJob(CancelDlpJobRequest $request, array $callOptions = $this->startApiCall('CancelDlpJob', $request, $callOptions)->wait(); } + /** + * Create a Connection to an external data source. + * + * The async variant is {@see DlpServiceClient::createConnectionAsync()} . + * + * @example samples/V2/DlpServiceClient/create_connection.php + * + * @param CreateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Connection + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConnection(CreateConnectionRequest $request, array $callOptions = []): Connection + { + return $this->startApiCall('CreateConnection', $request, $callOptions)->wait(); + } + /** * Creates a DeidentifyTemplate for reusing frequently used configuration * for de-identifying content, images, and storage. @@ -1236,6 +1297,30 @@ public function deidentifyContent(DeidentifyContentRequest $request, array $call return $this->startApiCall('DeidentifyContent', $request, $callOptions)->wait(); } + /** + * Delete a Connection. + * + * The async variant is {@see DlpServiceClient::deleteConnectionAsync()} . + * + * @example samples/V2/DlpServiceClient/delete_connection.php + * + * @param DeleteConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConnection(DeleteConnectionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteConnection', $request, $callOptions)->wait(); + } + /** * Deletes a DeidentifyTemplate. * See @@ -1399,6 +1484,31 @@ public function deleteStoredInfoType(DeleteStoredInfoTypeRequest $request, array $this->startApiCall('DeleteStoredInfoType', $request, $callOptions)->wait(); } + /** + * Delete a TableDataProfile. Will not prevent the profile from being + * regenerated if the table is still included in a discovery configuration. + * + * The async variant is {@see DlpServiceClient::deleteTableDataProfileAsync()} . + * + * @example samples/V2/DlpServiceClient/delete_table_data_profile.php + * + * @param DeleteTableDataProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTableDataProfile(DeleteTableDataProfileRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTableDataProfile', $request, $callOptions)->wait(); + } + /** * Finish a running hybrid DlpJob. Triggers the finalization steps and running * of any enabled actions that have not yet run. @@ -1450,6 +1560,32 @@ public function getColumnDataProfile(GetColumnDataProfileRequest $request, array return $this->startApiCall('GetColumnDataProfile', $request, $callOptions)->wait(); } + /** + * Get a Connection by name. + * + * The async variant is {@see DlpServiceClient::getConnectionAsync()} . + * + * @example samples/V2/DlpServiceClient/get_connection.php + * + * @param GetConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Connection + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConnection(GetConnectionRequest $request, array $callOptions = []): Connection + { + return $this->startApiCall('GetConnection', $request, $callOptions)->wait(); + } + /** * Gets a DeidentifyTemplate. * See @@ -1768,7 +1904,7 @@ public function inspectContent(InspectContentRequest $request, array $callOption } /** - * Lists data profiles for an organization. + * Lists column data profiles for an organization. * * The async variant is {@see DlpServiceClient::listColumnDataProfilesAsync()} . * @@ -1793,6 +1929,32 @@ public function listColumnDataProfiles(ListColumnDataProfilesRequest $request, a return $this->startApiCall('ListColumnDataProfiles', $request, $callOptions); } + /** + * Lists Connections in a parent. + * + * The async variant is {@see DlpServiceClient::listConnectionsAsync()} . + * + * @example samples/V2/DlpServiceClient/list_connections.php + * + * @param ListConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConnections(ListConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConnections', $request, $callOptions); + } + /** * Lists DeidentifyTemplates. * See @@ -1967,7 +2129,7 @@ public function listJobTriggers(ListJobTriggersRequest $request, array $callOpti } /** - * Lists data profiles for an organization. + * Lists project data profiles for an organization. * * The async variant is {@see DlpServiceClient::listProjectDataProfilesAsync()} . * @@ -2022,7 +2184,7 @@ public function listStoredInfoTypes(ListStoredInfoTypesRequest $request, array $ } /** - * Lists data profiles for an organization. + * Lists table data profiles for an organization. * * The async variant is {@see DlpServiceClient::listTableDataProfilesAsync()} . * @@ -2110,6 +2272,58 @@ public function reidentifyContent(ReidentifyContentRequest $request, array $call return $this->startApiCall('ReidentifyContent', $request, $callOptions)->wait(); } + /** + * Searches for Connections in a parent. + * + * The async variant is {@see DlpServiceClient::searchConnectionsAsync()} . + * + * @example samples/V2/DlpServiceClient/search_connections.php + * + * @param SearchConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchConnections(SearchConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchConnections', $request, $callOptions); + } + + /** + * Update a Connection. + * + * The async variant is {@see DlpServiceClient::updateConnectionAsync()} . + * + * @example samples/V2/DlpServiceClient/update_connection.php + * + * @param UpdateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Connection + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConnection(UpdateConnectionRequest $request, array $callOptions = []): Connection + { + return $this->startApiCall('UpdateConnection', $request, $callOptions)->wait(); + } + /** * Updates the DeidentifyTemplate. * See diff --git a/Dlp/src/V2/CloudSqlDiscoveryTarget.php b/Dlp/src/V2/CloudSqlDiscoveryTarget.php new file mode 100644 index 000000000000..16069108161d --- /dev/null +++ b/Dlp/src/V2/CloudSqlDiscoveryTarget.php @@ -0,0 +1,210 @@ +google.privacy.dlp.v2.CloudSqlDiscoveryTarget + */ +class CloudSqlDiscoveryTarget extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The tables the discovery cadence applies to. The first target + * with a matching filter will be the one to apply to a table. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlFilter filter = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $filter = null; + /** + * In addition to matching the filter, these conditions must be true + * before a profile is generated. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlConditions conditions = 2; + */ + private $conditions = null; + protected $cadence; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Dlp\V2\DiscoveryCloudSqlFilter $filter + * Required. The tables the discovery cadence applies to. The first target + * with a matching filter will be the one to apply to a table. + * @type \Google\Cloud\Dlp\V2\DiscoveryCloudSqlConditions $conditions + * In addition to matching the filter, these conditions must be true + * before a profile is generated. + * @type \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence $generation_cadence + * How often and when to update profiles. New tables that match both the + * filter and conditions are scanned as quickly as possible depending on + * system capacity. + * @type \Google\Cloud\Dlp\V2\Disabled $disabled + * Disable profiling for database resources that match this filter. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Required. The tables the discovery cadence applies to. The first target + * with a matching filter will be the one to apply to a table. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlFilter filter = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Dlp\V2\DiscoveryCloudSqlFilter|null + */ + public function getFilter() + { + return $this->filter; + } + + public function hasFilter() + { + return isset($this->filter); + } + + public function clearFilter() + { + unset($this->filter); + } + + /** + * Required. The tables the discovery cadence applies to. The first target + * with a matching filter will be the one to apply to a table. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlFilter filter = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Dlp\V2\DiscoveryCloudSqlFilter $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlFilter::class); + $this->filter = $var; + + return $this; + } + + /** + * In addition to matching the filter, these conditions must be true + * before a profile is generated. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlConditions conditions = 2; + * @return \Google\Cloud\Dlp\V2\DiscoveryCloudSqlConditions|null + */ + public function getConditions() + { + return $this->conditions; + } + + public function hasConditions() + { + return isset($this->conditions); + } + + public function clearConditions() + { + unset($this->conditions); + } + + /** + * In addition to matching the filter, these conditions must be true + * before a profile is generated. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlConditions conditions = 2; + * @param \Google\Cloud\Dlp\V2\DiscoveryCloudSqlConditions $var + * @return $this + */ + public function setConditions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlConditions::class); + $this->conditions = $var; + + return $this; + } + + /** + * How often and when to update profiles. New tables that match both the + * filter and conditions are scanned as quickly as possible depending on + * system capacity. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence generation_cadence = 3; + * @return \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence|null + */ + public function getGenerationCadence() + { + return $this->readOneof(3); + } + + public function hasGenerationCadence() + { + return $this->hasOneof(3); + } + + /** + * How often and when to update profiles. New tables that match both the + * filter and conditions are scanned as quickly as possible depending on + * system capacity. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence generation_cadence = 3; + * @param \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence $var + * @return $this + */ + public function setGenerationCadence($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Disable profiling for database resources that match this filter. + * + * Generated from protobuf field .google.privacy.dlp.v2.Disabled disabled = 4; + * @return \Google\Cloud\Dlp\V2\Disabled|null + */ + public function getDisabled() + { + return $this->readOneof(4); + } + + public function hasDisabled() + { + return $this->hasOneof(4); + } + + /** + * Disable profiling for database resources that match this filter. + * + * Generated from protobuf field .google.privacy.dlp.v2.Disabled disabled = 4; + * @param \Google\Cloud\Dlp\V2\Disabled $var + * @return $this + */ + public function setDisabled($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Disabled::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * @return string + */ + public function getCadence() + { + return $this->whichOneof("cadence"); + } + +} + diff --git a/Dlp/src/V2/CloudSqlIamCredential.php b/Dlp/src/V2/CloudSqlIamCredential.php new file mode 100644 index 000000000000..24f7585f2adb --- /dev/null +++ b/Dlp/src/V2/CloudSqlIamCredential.php @@ -0,0 +1,36 @@ +google.privacy.dlp.v2.CloudSqlIamCredential + */ +class CloudSqlIamCredential extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + +} + diff --git a/Dlp/src/V2/CloudSqlProperties.php b/Dlp/src/V2/CloudSqlProperties.php new file mode 100644 index 000000000000..0e00cbbe9948 --- /dev/null +++ b/Dlp/src/V2/CloudSqlProperties.php @@ -0,0 +1,250 @@ +google.privacy.dlp.v2.CloudSqlProperties + */ +class CloudSqlProperties extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Immutable. The Cloud SQL instance for which the connection is + * defined. Only one connection per instance is allowed. This can only be set + * at creation time, and cannot be updated. + * It is an error to use a connection_name from different project or region + * than the one that holds the connection. + * For example, a Connection resource for Cloud SQL connection_name + * `project-id:us-central1:sql-instance` + * must be created under the parent + * `projects/project-id/locations/us-central1` + * + * Generated from protobuf field string connection_name = 1 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + */ + private $connection_name = ''; + /** + * Required. DLP will limit its connections to max_connections. + * Must be 2 or greater. + * + * Generated from protobuf field int32 max_connections = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + private $max_connections = 0; + /** + * Required. The database engine used by the Cloud SQL instance that this + * connection configures. + * + * Generated from protobuf field .google.privacy.dlp.v2.CloudSqlProperties.DatabaseEngine database_engine = 7 [(.google.api.field_behavior) = REQUIRED]; + */ + private $database_engine = 0; + protected $credential; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $connection_name + * Optional. Immutable. The Cloud SQL instance for which the connection is + * defined. Only one connection per instance is allowed. This can only be set + * at creation time, and cannot be updated. + * It is an error to use a connection_name from different project or region + * than the one that holds the connection. + * For example, a Connection resource for Cloud SQL connection_name + * `project-id:us-central1:sql-instance` + * must be created under the parent + * `projects/project-id/locations/us-central1` + * @type \Google\Cloud\Dlp\V2\SecretManagerCredential $username_password + * A username and password stored in Secret Manager. + * @type \Google\Cloud\Dlp\V2\CloudSqlIamCredential $cloud_sql_iam + * Built-in IAM authentication (must be configured in Cloud SQL). + * @type int $max_connections + * Required. DLP will limit its connections to max_connections. + * Must be 2 or greater. + * @type int $database_engine + * Required. The database engine used by the Cloud SQL instance that this + * connection configures. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Immutable. The Cloud SQL instance for which the connection is + * defined. Only one connection per instance is allowed. This can only be set + * at creation time, and cannot be updated. + * It is an error to use a connection_name from different project or region + * than the one that holds the connection. + * For example, a Connection resource for Cloud SQL connection_name + * `project-id:us-central1:sql-instance` + * must be created under the parent + * `projects/project-id/locations/us-central1` + * + * Generated from protobuf field string connection_name = 1 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getConnectionName() + { + return $this->connection_name; + } + + /** + * Optional. Immutable. The Cloud SQL instance for which the connection is + * defined. Only one connection per instance is allowed. This can only be set + * at creation time, and cannot be updated. + * It is an error to use a connection_name from different project or region + * than the one that holds the connection. + * For example, a Connection resource for Cloud SQL connection_name + * `project-id:us-central1:sql-instance` + * must be created under the parent + * `projects/project-id/locations/us-central1` + * + * Generated from protobuf field string connection_name = 1 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setConnectionName($var) + { + GPBUtil::checkString($var, True); + $this->connection_name = $var; + + return $this; + } + + /** + * A username and password stored in Secret Manager. + * + * Generated from protobuf field .google.privacy.dlp.v2.SecretManagerCredential username_password = 2; + * @return \Google\Cloud\Dlp\V2\SecretManagerCredential|null + */ + public function getUsernamePassword() + { + return $this->readOneof(2); + } + + public function hasUsernamePassword() + { + return $this->hasOneof(2); + } + + /** + * A username and password stored in Secret Manager. + * + * Generated from protobuf field .google.privacy.dlp.v2.SecretManagerCredential username_password = 2; + * @param \Google\Cloud\Dlp\V2\SecretManagerCredential $var + * @return $this + */ + public function setUsernamePassword($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\SecretManagerCredential::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Built-in IAM authentication (must be configured in Cloud SQL). + * + * Generated from protobuf field .google.privacy.dlp.v2.CloudSqlIamCredential cloud_sql_iam = 3; + * @return \Google\Cloud\Dlp\V2\CloudSqlIamCredential|null + */ + public function getCloudSqlIam() + { + return $this->readOneof(3); + } + + public function hasCloudSqlIam() + { + return $this->hasOneof(3); + } + + /** + * Built-in IAM authentication (must be configured in Cloud SQL). + * + * Generated from protobuf field .google.privacy.dlp.v2.CloudSqlIamCredential cloud_sql_iam = 3; + * @param \Google\Cloud\Dlp\V2\CloudSqlIamCredential $var + * @return $this + */ + public function setCloudSqlIam($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CloudSqlIamCredential::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Required. DLP will limit its connections to max_connections. + * Must be 2 or greater. + * + * Generated from protobuf field int32 max_connections = 4 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getMaxConnections() + { + return $this->max_connections; + } + + /** + * Required. DLP will limit its connections to max_connections. + * Must be 2 or greater. + * + * Generated from protobuf field int32 max_connections = 4 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setMaxConnections($var) + { + GPBUtil::checkInt32($var); + $this->max_connections = $var; + + return $this; + } + + /** + * Required. The database engine used by the Cloud SQL instance that this + * connection configures. + * + * Generated from protobuf field .google.privacy.dlp.v2.CloudSqlProperties.DatabaseEngine database_engine = 7 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getDatabaseEngine() + { + return $this->database_engine; + } + + /** + * Required. The database engine used by the Cloud SQL instance that this + * connection configures. + * + * Generated from protobuf field .google.privacy.dlp.v2.CloudSqlProperties.DatabaseEngine database_engine = 7 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setDatabaseEngine($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Dlp\V2\CloudSqlProperties\DatabaseEngine::class); + $this->database_engine = $var; + + return $this; + } + + /** + * @return string + */ + public function getCredential() + { + return $this->whichOneof("credential"); + } + +} + diff --git a/Dlp/src/V2/CloudSqlProperties/DatabaseEngine.php b/Dlp/src/V2/CloudSqlProperties/DatabaseEngine.php new file mode 100644 index 000000000000..17cbeb998f1c --- /dev/null +++ b/Dlp/src/V2/CloudSqlProperties/DatabaseEngine.php @@ -0,0 +1,65 @@ +google.privacy.dlp.v2.CloudSqlProperties.DatabaseEngine + */ +class DatabaseEngine +{ + /** + * An engine that is not currently supported by SDP. + * + * Generated from protobuf enum DATABASE_ENGINE_UNKNOWN = 0; + */ + const DATABASE_ENGINE_UNKNOWN = 0; + /** + * Cloud SQL for MySQL instance. + * + * Generated from protobuf enum DATABASE_ENGINE_MYSQL = 1; + */ + const DATABASE_ENGINE_MYSQL = 1; + /** + * Cloud SQL for Postgres instance. + * + * Generated from protobuf enum DATABASE_ENGINE_POSTGRES = 2; + */ + const DATABASE_ENGINE_POSTGRES = 2; + + private static $valueToName = [ + self::DATABASE_ENGINE_UNKNOWN => 'DATABASE_ENGINE_UNKNOWN', + self::DATABASE_ENGINE_MYSQL => 'DATABASE_ENGINE_MYSQL', + self::DATABASE_ENGINE_POSTGRES => 'DATABASE_ENGINE_POSTGRES', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(DatabaseEngine::class, \Google\Cloud\Dlp\V2\CloudSqlProperties_DatabaseEngine::class); + diff --git a/Dlp/src/V2/ColumnDataProfile/ColumnDataType.php b/Dlp/src/V2/ColumnDataProfile/ColumnDataType.php index 2688d3a1aa3a..83faea00b595 100644 --- a/Dlp/src/V2/ColumnDataProfile/ColumnDataType.php +++ b/Dlp/src/V2/ColumnDataProfile/ColumnDataType.php @@ -104,6 +104,30 @@ class ColumnDataType * Generated from protobuf enum TYPE_JSON = 14; */ const TYPE_JSON = 14; + /** + * Interval type. + * + * Generated from protobuf enum TYPE_INTERVAL = 15; + */ + const TYPE_INTERVAL = 15; + /** + * `Range` type. + * + * Generated from protobuf enum TYPE_RANGE_DATE = 16; + */ + const TYPE_RANGE_DATE = 16; + /** + * `Range` type. + * + * Generated from protobuf enum TYPE_RANGE_DATETIME = 17; + */ + const TYPE_RANGE_DATETIME = 17; + /** + * `Range` type. + * + * Generated from protobuf enum TYPE_RANGE_TIMESTAMP = 18; + */ + const TYPE_RANGE_TIMESTAMP = 18; private static $valueToName = [ self::COLUMN_DATA_TYPE_UNSPECIFIED => 'COLUMN_DATA_TYPE_UNSPECIFIED', @@ -121,6 +145,10 @@ class ColumnDataType self::TYPE_RECORD => 'TYPE_RECORD', self::TYPE_BIGNUMERIC => 'TYPE_BIGNUMERIC', self::TYPE_JSON => 'TYPE_JSON', + self::TYPE_INTERVAL => 'TYPE_INTERVAL', + self::TYPE_RANGE_DATE => 'TYPE_RANGE_DATE', + self::TYPE_RANGE_DATETIME => 'TYPE_RANGE_DATETIME', + self::TYPE_RANGE_TIMESTAMP => 'TYPE_RANGE_TIMESTAMP', ]; public static function name($value) diff --git a/Dlp/src/V2/Connection.php b/Dlp/src/V2/Connection.php new file mode 100644 index 000000000000..43fb43a43d20 --- /dev/null +++ b/Dlp/src/V2/Connection.php @@ -0,0 +1,186 @@ +google.privacy.dlp.v2.Connection + */ +class Connection extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Name of the connection: + * `projects/{project}/locations/{location}/connections/{name}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $name = ''; + /** + * Required. The connection's state in its lifecycle. + * + * Generated from protobuf field .google.privacy.dlp.v2.ConnectionState state = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $state = 0; + /** + * Output only. Set if status == ERROR, to provide additional details. Will + * store the last 10 errors sorted with the most recent first. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.Error errors = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $errors; + protected $properties; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Output only. Name of the connection: + * `projects/{project}/locations/{location}/connections/{name}`. + * @type int $state + * Required. The connection's state in its lifecycle. + * @type array<\Google\Cloud\Dlp\V2\Error>|\Google\Protobuf\Internal\RepeatedField $errors + * Output only. Set if status == ERROR, to provide additional details. Will + * store the last 10 errors sorted with the most recent first. + * @type \Google\Cloud\Dlp\V2\CloudSqlProperties $cloud_sql + * Connect to a Cloud SQL instance. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Output only. Name of the connection: + * `projects/{project}/locations/{location}/connections/{name}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. Name of the connection: + * `projects/{project}/locations/{location}/connections/{name}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The connection's state in its lifecycle. + * + * Generated from protobuf field .google.privacy.dlp.v2.ConnectionState state = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getState() + { + return $this->state; + } + + /** + * Required. The connection's state in its lifecycle. + * + * Generated from protobuf field .google.privacy.dlp.v2.ConnectionState state = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Dlp\V2\ConnectionState::class); + $this->state = $var; + + return $this; + } + + /** + * Output only. Set if status == ERROR, to provide additional details. Will + * store the last 10 errors sorted with the most recent first. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.Error errors = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getErrors() + { + return $this->errors; + } + + /** + * Output only. Set if status == ERROR, to provide additional details. Will + * store the last 10 errors sorted with the most recent first. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.Error errors = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param array<\Google\Cloud\Dlp\V2\Error>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setErrors($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\Error::class); + $this->errors = $arr; + + return $this; + } + + /** + * Connect to a Cloud SQL instance. + * + * Generated from protobuf field .google.privacy.dlp.v2.CloudSqlProperties cloud_sql = 4; + * @return \Google\Cloud\Dlp\V2\CloudSqlProperties|null + */ + public function getCloudSql() + { + return $this->readOneof(4); + } + + public function hasCloudSql() + { + return $this->hasOneof(4); + } + + /** + * Connect to a Cloud SQL instance. + * + * Generated from protobuf field .google.privacy.dlp.v2.CloudSqlProperties cloud_sql = 4; + * @param \Google\Cloud\Dlp\V2\CloudSqlProperties $var + * @return $this + */ + public function setCloudSql($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CloudSqlProperties::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * @return string + */ + public function getProperties() + { + return $this->whichOneof("properties"); + } + +} + diff --git a/Dlp/src/V2/ConnectionState.php b/Dlp/src/V2/ConnectionState.php new file mode 100644 index 000000000000..8217300c3910 --- /dev/null +++ b/Dlp/src/V2/ConnectionState.php @@ -0,0 +1,75 @@ +google.privacy.dlp.v2.ConnectionState + */ +class ConnectionState +{ + /** + * Unused + * + * Generated from protobuf enum CONNECTION_STATE_UNSPECIFIED = 0; + */ + const CONNECTION_STATE_UNSPECIFIED = 0; + /** + * DLP automatically created this connection during an initial scan, and it is + * awaiting full configuration by a user. + * + * Generated from protobuf enum MISSING_CREDENTIALS = 1; + */ + const MISSING_CREDENTIALS = 1; + /** + * A configured connection that has not encountered any errors. + * + * Generated from protobuf enum AVAILABLE = 2; + */ + const AVAILABLE = 2; + /** + * A configured connection that encountered errors during its last use. It + * will not be used again until it is set to AVAILABLE. + * If the resolution requires external action, then a request to set the + * status to AVAILABLE will mark this connection for use. Otherwise, any + * changes to the connection properties will automatically mark it as + * AVAILABLE. + * + * Generated from protobuf enum ERROR = 3; + */ + const ERROR = 3; + + private static $valueToName = [ + self::CONNECTION_STATE_UNSPECIFIED => 'CONNECTION_STATE_UNSPECIFIED', + self::MISSING_CREDENTIALS => 'MISSING_CREDENTIALS', + self::AVAILABLE => 'AVAILABLE', + self::ERROR => 'ERROR', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/Dlp/src/V2/CreateConnectionRequest.php b/Dlp/src/V2/CreateConnectionRequest.php new file mode 100644 index 000000000000..81398dd6d830 --- /dev/null +++ b/Dlp/src/V2/CreateConnectionRequest.php @@ -0,0 +1,132 @@ +google.privacy.dlp.v2.CreateConnectionRequest + */ +class CreateConnectionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Parent resource name in the format: + * `projects/{project}/locations/{location}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. The connection resource. + * + * Generated from protobuf field .google.privacy.dlp.v2.Connection connection = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $connection = null; + + /** + * @param string $parent Required. Parent resource name in the format: + * `projects/{project}/locations/{location}`. Please see + * {@see DlpServiceClient::locationName()} for help formatting this field. + * @param \Google\Cloud\Dlp\V2\Connection $connection Required. The connection resource. + * + * @return \Google\Cloud\Dlp\V2\CreateConnectionRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dlp\V2\Connection $connection): self + { + return (new self()) + ->setParent($parent) + ->setConnection($connection); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. Parent resource name in the format: + * `projects/{project}/locations/{location}`. + * @type \Google\Cloud\Dlp\V2\Connection $connection + * Required. The connection resource. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Required. Parent resource name in the format: + * `projects/{project}/locations/{location}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. Parent resource name in the format: + * `projects/{project}/locations/{location}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The connection resource. + * + * Generated from protobuf field .google.privacy.dlp.v2.Connection connection = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Dlp\V2\Connection|null + */ + public function getConnection() + { + return $this->connection; + } + + public function hasConnection() + { + return isset($this->connection); + } + + public function clearConnection() + { + unset($this->connection); + } + + /** + * Required. The connection resource. + * + * Generated from protobuf field .google.privacy.dlp.v2.Connection connection = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Dlp\V2\Connection $var + * @return $this + */ + public function setConnection($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Connection::class); + $this->connection = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/DataProfileAction/EventType.php b/Dlp/src/V2/DataProfileAction/EventType.php index 1babed97ae5d..51cee6a4953d 100644 --- a/Dlp/src/V2/DataProfileAction/EventType.php +++ b/Dlp/src/V2/DataProfileAction/EventType.php @@ -27,12 +27,12 @@ class EventType const NEW_PROFILE = 1; /** * Changed one of the following profile metrics: - * * Table data risk score - * * Table sensitivity score - * * Table resource visibility - * * Table encryption type - * * Table predicted infoTypes - * * Table other infoTypes + * * Data risk score + * * Sensitivity score + * * Resource visibility + * * Encryption type + * * Predicted infoTypes + * * Other infoTypes * * Generated from protobuf enum CHANGED_PROFILE = 2; */ diff --git a/Dlp/src/V2/DataProfileAction/Export.php b/Dlp/src/V2/DataProfileAction/Export.php index 6a682f018cef..685e22531e42 100644 --- a/Dlp/src/V2/DataProfileAction/Export.php +++ b/Dlp/src/V2/DataProfileAction/Export.php @@ -18,8 +18,14 @@ class Export extends \Google\Protobuf\Internal\Message { /** * Store all table and column profiles in an existing table or a new table - * in an existing dataset. Each re-generation will result in a new row in - * BigQuery. + * in an existing dataset. Each re-generation will result in new rows in + * BigQuery. Data is inserted using [streaming + * insert](https://cloud.google.com/blog/products/bigquery/life-of-a-bigquery-streaming-insert) + * and so data may be in the buffer for a period of time after the profile + * has finished. The Pub/Sub notification is sent before the streaming + * buffer is guaranteed to be written, so data may not be instantly + * visible to queries by the time your topic receives the Pub/Sub + * notification. * * Generated from protobuf field .google.privacy.dlp.v2.BigQueryTable profile_table = 1; */ @@ -33,8 +39,14 @@ class Export extends \Google\Protobuf\Internal\Message * * @type \Google\Cloud\Dlp\V2\BigQueryTable $profile_table * Store all table and column profiles in an existing table or a new table - * in an existing dataset. Each re-generation will result in a new row in - * BigQuery. + * in an existing dataset. Each re-generation will result in new rows in + * BigQuery. Data is inserted using [streaming + * insert](https://cloud.google.com/blog/products/bigquery/life-of-a-bigquery-streaming-insert) + * and so data may be in the buffer for a period of time after the profile + * has finished. The Pub/Sub notification is sent before the streaming + * buffer is guaranteed to be written, so data may not be instantly + * visible to queries by the time your topic receives the Pub/Sub + * notification. * } */ public function __construct($data = NULL) { @@ -44,8 +56,14 @@ public function __construct($data = NULL) { /** * Store all table and column profiles in an existing table or a new table - * in an existing dataset. Each re-generation will result in a new row in - * BigQuery. + * in an existing dataset. Each re-generation will result in new rows in + * BigQuery. Data is inserted using [streaming + * insert](https://cloud.google.com/blog/products/bigquery/life-of-a-bigquery-streaming-insert) + * and so data may be in the buffer for a period of time after the profile + * has finished. The Pub/Sub notification is sent before the streaming + * buffer is guaranteed to be written, so data may not be instantly + * visible to queries by the time your topic receives the Pub/Sub + * notification. * * Generated from protobuf field .google.privacy.dlp.v2.BigQueryTable profile_table = 1; * @return \Google\Cloud\Dlp\V2\BigQueryTable|null @@ -67,8 +85,14 @@ public function clearProfileTable() /** * Store all table and column profiles in an existing table or a new table - * in an existing dataset. Each re-generation will result in a new row in - * BigQuery. + * in an existing dataset. Each re-generation will result in new rows in + * BigQuery. Data is inserted using [streaming + * insert](https://cloud.google.com/blog/products/bigquery/life-of-a-bigquery-streaming-insert) + * and so data may be in the buffer for a period of time after the profile + * has finished. The Pub/Sub notification is sent before the streaming + * buffer is guaranteed to be written, so data may not be instantly + * visible to queries by the time your topic receives the Pub/Sub + * notification. * * Generated from protobuf field .google.privacy.dlp.v2.BigQueryTable profile_table = 1; * @param \Google\Cloud\Dlp\V2\BigQueryTable $var diff --git a/Dlp/src/V2/DataProfileAction/PubSubNotification/DetailLevel.php b/Dlp/src/V2/DataProfileAction/PubSubNotification/DetailLevel.php index c5bfd5a9b631..3367ba04d4e6 100644 --- a/Dlp/src/V2/DataProfileAction/PubSubNotification/DetailLevel.php +++ b/Dlp/src/V2/DataProfileAction/PubSubNotification/DetailLevel.php @@ -26,7 +26,7 @@ class DetailLevel */ const TABLE_PROFILE = 1; /** - * The resource name of the table. + * The name of the profiled resource. * * Generated from protobuf enum RESOURCE_NAME = 2; */ diff --git a/Dlp/src/V2/DatabaseResourceCollection.php b/Dlp/src/V2/DatabaseResourceCollection.php new file mode 100644 index 000000000000..61a1ce7130dd --- /dev/null +++ b/Dlp/src/V2/DatabaseResourceCollection.php @@ -0,0 +1,76 @@ +google.privacy.dlp.v2.DatabaseResourceCollection + */ +class DatabaseResourceCollection extends \Google\Protobuf\Internal\Message +{ + protected $pattern; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Dlp\V2\DatabaseResourceRegexes $include_regexes + * A collection of regular expressions to match a database resource against. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * A collection of regular expressions to match a database resource against. + * + * Generated from protobuf field .google.privacy.dlp.v2.DatabaseResourceRegexes include_regexes = 1; + * @return \Google\Cloud\Dlp\V2\DatabaseResourceRegexes|null + */ + public function getIncludeRegexes() + { + return $this->readOneof(1); + } + + public function hasIncludeRegexes() + { + return $this->hasOneof(1); + } + + /** + * A collection of regular expressions to match a database resource against. + * + * Generated from protobuf field .google.privacy.dlp.v2.DatabaseResourceRegexes include_regexes = 1; + * @param \Google\Cloud\Dlp\V2\DatabaseResourceRegexes $var + * @return $this + */ + public function setIncludeRegexes($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\DatabaseResourceRegexes::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * @return string + */ + public function getPattern() + { + return $this->whichOneof("pattern"); + } + +} + diff --git a/Dlp/src/V2/DatabaseResourceReference.php b/Dlp/src/V2/DatabaseResourceReference.php new file mode 100644 index 000000000000..6bb585aa212f --- /dev/null +++ b/Dlp/src/V2/DatabaseResourceReference.php @@ -0,0 +1,109 @@ +google.privacy.dlp.v2.DatabaseResourceReference + */ +class DatabaseResourceReference extends \Google\Protobuf\Internal\Message +{ + /** + * Required. If within a project-level config, then this must match the + * config's project id. + * + * Generated from protobuf field string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $project_id = ''; + /** + * Required. The instance where this resource is located. For example: Cloud + * SQL's instance id. + * + * Generated from protobuf field string instance = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $instance = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $project_id + * Required. If within a project-level config, then this must match the + * config's project id. + * @type string $instance + * Required. The instance where this resource is located. For example: Cloud + * SQL's instance id. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Required. If within a project-level config, then this must match the + * config's project id. + * + * Generated from protobuf field string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * Required. If within a project-level config, then this must match the + * config's project id. + * + * Generated from protobuf field string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setProjectId($var) + { + GPBUtil::checkString($var, True); + $this->project_id = $var; + + return $this; + } + + /** + * Required. The instance where this resource is located. For example: Cloud + * SQL's instance id. + * + * Generated from protobuf field string instance = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getInstance() + { + return $this->instance; + } + + /** + * Required. The instance where this resource is located. For example: Cloud + * SQL's instance id. + * + * Generated from protobuf field string instance = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setInstance($var) + { + GPBUtil::checkString($var, True); + $this->instance = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/DatabaseResourceRegex.php b/Dlp/src/V2/DatabaseResourceRegex.php new file mode 100644 index 000000000000..94a832755dd5 --- /dev/null +++ b/Dlp/src/V2/DatabaseResourceRegex.php @@ -0,0 +1,188 @@ +google.privacy.dlp.v2.DatabaseResourceRegex + */ +class DatabaseResourceRegex extends \Google\Protobuf\Internal\Message +{ + /** + * For organizations, if unset, will match all projects. Has no effect + * for Data Profile configurations created within a project. + * + * Generated from protobuf field string project_id_regex = 1; + */ + private $project_id_regex = ''; + /** + * Regex to test the instance name against. If empty, all instances match. + * + * Generated from protobuf field string instance_regex = 2; + */ + private $instance_regex = ''; + /** + * Regex to test the database name against. If empty, all databases match. + * + * Generated from protobuf field string database_regex = 3; + */ + private $database_regex = ''; + /** + * Regex to test the database resource's name against. An example of a + * database resource name is a table's name. Other database resource names + * like view names could be included in the future. If empty, all database + * resources match. + * + * Generated from protobuf field string database_resource_name_regex = 4; + */ + private $database_resource_name_regex = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $project_id_regex + * For organizations, if unset, will match all projects. Has no effect + * for Data Profile configurations created within a project. + * @type string $instance_regex + * Regex to test the instance name against. If empty, all instances match. + * @type string $database_regex + * Regex to test the database name against. If empty, all databases match. + * @type string $database_resource_name_regex + * Regex to test the database resource's name against. An example of a + * database resource name is a table's name. Other database resource names + * like view names could be included in the future. If empty, all database + * resources match. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * For organizations, if unset, will match all projects. Has no effect + * for Data Profile configurations created within a project. + * + * Generated from protobuf field string project_id_regex = 1; + * @return string + */ + public function getProjectIdRegex() + { + return $this->project_id_regex; + } + + /** + * For organizations, if unset, will match all projects. Has no effect + * for Data Profile configurations created within a project. + * + * Generated from protobuf field string project_id_regex = 1; + * @param string $var + * @return $this + */ + public function setProjectIdRegex($var) + { + GPBUtil::checkString($var, True); + $this->project_id_regex = $var; + + return $this; + } + + /** + * Regex to test the instance name against. If empty, all instances match. + * + * Generated from protobuf field string instance_regex = 2; + * @return string + */ + public function getInstanceRegex() + { + return $this->instance_regex; + } + + /** + * Regex to test the instance name against. If empty, all instances match. + * + * Generated from protobuf field string instance_regex = 2; + * @param string $var + * @return $this + */ + public function setInstanceRegex($var) + { + GPBUtil::checkString($var, True); + $this->instance_regex = $var; + + return $this; + } + + /** + * Regex to test the database name against. If empty, all databases match. + * + * Generated from protobuf field string database_regex = 3; + * @return string + */ + public function getDatabaseRegex() + { + return $this->database_regex; + } + + /** + * Regex to test the database name against. If empty, all databases match. + * + * Generated from protobuf field string database_regex = 3; + * @param string $var + * @return $this + */ + public function setDatabaseRegex($var) + { + GPBUtil::checkString($var, True); + $this->database_regex = $var; + + return $this; + } + + /** + * Regex to test the database resource's name against. An example of a + * database resource name is a table's name. Other database resource names + * like view names could be included in the future. If empty, all database + * resources match. + * + * Generated from protobuf field string database_resource_name_regex = 4; + * @return string + */ + public function getDatabaseResourceNameRegex() + { + return $this->database_resource_name_regex; + } + + /** + * Regex to test the database resource's name against. An example of a + * database resource name is a table's name. Other database resource names + * like view names could be included in the future. If empty, all database + * resources match. + * + * Generated from protobuf field string database_resource_name_regex = 4; + * @param string $var + * @return $this + */ + public function setDatabaseResourceNameRegex($var) + { + GPBUtil::checkString($var, True); + $this->database_resource_name_regex = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/DatabaseResourceRegexes.php b/Dlp/src/V2/DatabaseResourceRegexes.php new file mode 100644 index 000000000000..c9a5d6122541 --- /dev/null +++ b/Dlp/src/V2/DatabaseResourceRegexes.php @@ -0,0 +1,80 @@ +google.privacy.dlp.v2.DatabaseResourceRegexes + */ +class DatabaseResourceRegexes extends \Google\Protobuf\Internal\Message +{ + /** + * A group of regular expression patterns to match against one or more + * database resources. + * Maximum of 100 entries. The sum of all regular expression's length can't + * exceed 10 KiB. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DatabaseResourceRegex patterns = 1; + */ + private $patterns; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Dlp\V2\DatabaseResourceRegex>|\Google\Protobuf\Internal\RepeatedField $patterns + * A group of regular expression patterns to match against one or more + * database resources. + * Maximum of 100 entries. The sum of all regular expression's length can't + * exceed 10 KiB. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * A group of regular expression patterns to match against one or more + * database resources. + * Maximum of 100 entries. The sum of all regular expression's length can't + * exceed 10 KiB. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DatabaseResourceRegex patterns = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPatterns() + { + return $this->patterns; + } + + /** + * A group of regular expression patterns to match against one or more + * database resources. + * Maximum of 100 entries. The sum of all regular expression's length can't + * exceed 10 KiB. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DatabaseResourceRegex patterns = 1; + * @param array<\Google\Cloud\Dlp\V2\DatabaseResourceRegex>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPatterns($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\DatabaseResourceRegex::class); + $this->patterns = $arr; + + return $this; + } + +} + diff --git a/Dlp/src/V2/DeleteConnectionRequest.php b/Dlp/src/V2/DeleteConnectionRequest.php new file mode 100644 index 000000000000..eb78e2f95805 --- /dev/null +++ b/Dlp/src/V2/DeleteConnectionRequest.php @@ -0,0 +1,86 @@ +google.privacy.dlp.v2.DeleteConnectionRequest + */ +class DeleteConnectionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Resource name of the Connection to be deleted, in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * @param string $name Required. 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. + * + * @return \Google\Cloud\Dlp\V2\DeleteConnectionRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Resource name of the Connection to be deleted, in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Required. Resource name of the Connection to be deleted, in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. Resource name of the Connection to be deleted, in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/DeleteTableDataProfileRequest.php b/Dlp/src/V2/DeleteTableDataProfileRequest.php new file mode 100644 index 000000000000..f49b35b95b61 --- /dev/null +++ b/Dlp/src/V2/DeleteTableDataProfileRequest.php @@ -0,0 +1,81 @@ +google.privacy.dlp.v2.DeleteTableDataProfileRequest + */ +class DeleteTableDataProfileRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Resource name of the table data profile. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * @param string $name Required. Resource name of the table data profile. Please see + * {@see DlpServiceClient::tableDataProfileName()} for help formatting this field. + * + * @return \Google\Cloud\Dlp\V2\DeleteTableDataProfileRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Resource name of the table data profile. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Required. Resource name of the table data profile. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. Resource name of the table data profile. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/DiscoveryCloudSqlConditions.php b/Dlp/src/V2/DiscoveryCloudSqlConditions.php new file mode 100644 index 000000000000..0697e79227ac --- /dev/null +++ b/Dlp/src/V2/DiscoveryCloudSqlConditions.php @@ -0,0 +1,114 @@ +google.privacy.dlp.v2.DiscoveryCloudSqlConditions + */ +class DiscoveryCloudSqlConditions extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Database engines that should be profiled. + * Optional. Defaults to ALL_SUPPORTED_DATABASE_ENGINES if unspecified. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DiscoveryCloudSqlConditions.DatabaseEngine database_engines = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $database_engines; + /** + * Data profiles will only be generated for the database resource types + * specified in this field. + * If not specified, defaults to [DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES]. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DiscoveryCloudSqlConditions.DatabaseResourceType types = 3; + */ + private $types; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $database_engines + * Optional. Database engines that should be profiled. + * Optional. Defaults to ALL_SUPPORTED_DATABASE_ENGINES if unspecified. + * @type array|\Google\Protobuf\Internal\RepeatedField $types + * Data profiles will only be generated for the database resource types + * specified in this field. + * If not specified, defaults to [DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Database engines that should be profiled. + * Optional. Defaults to ALL_SUPPORTED_DATABASE_ENGINES if unspecified. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DiscoveryCloudSqlConditions.DatabaseEngine database_engines = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDatabaseEngines() + { + return $this->database_engines; + } + + /** + * Optional. Database engines that should be profiled. + * Optional. Defaults to ALL_SUPPORTED_DATABASE_ENGINES if unspecified. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DiscoveryCloudSqlConditions.DatabaseEngine database_engines = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDatabaseEngines($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlConditions\DatabaseEngine::class); + $this->database_engines = $arr; + + return $this; + } + + /** + * Data profiles will only be generated for the database resource types + * specified in this field. + * If not specified, defaults to [DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES]. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DiscoveryCloudSqlConditions.DatabaseResourceType types = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getTypes() + { + return $this->types; + } + + /** + * Data profiles will only be generated for the database resource types + * specified in this field. + * If not specified, defaults to [DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES]. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DiscoveryCloudSqlConditions.DatabaseResourceType types = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setTypes($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlConditions\DatabaseResourceType::class); + $this->types = $arr; + + return $this; + } + +} + diff --git a/Dlp/src/V2/DiscoveryCloudSqlConditions/DatabaseEngine.php b/Dlp/src/V2/DiscoveryCloudSqlConditions/DatabaseEngine.php new file mode 100644 index 000000000000..77ce5455887b --- /dev/null +++ b/Dlp/src/V2/DiscoveryCloudSqlConditions/DatabaseEngine.php @@ -0,0 +1,71 @@ +google.privacy.dlp.v2.DiscoveryCloudSqlConditions.DatabaseEngine + */ +class DatabaseEngine +{ + /** + * Unused. + * + * Generated from protobuf enum DATABASE_ENGINE_UNSPECIFIED = 0; + */ + const DATABASE_ENGINE_UNSPECIFIED = 0; + /** + * Include all supported database engines. + * + * Generated from protobuf enum ALL_SUPPORTED_DATABASE_ENGINES = 1; + */ + const ALL_SUPPORTED_DATABASE_ENGINES = 1; + /** + * MySql database. + * + * Generated from protobuf enum MYSQL = 2; + */ + const MYSQL = 2; + /** + * PostGres database. + * + * Generated from protobuf enum POSTGRES = 3; + */ + const POSTGRES = 3; + + private static $valueToName = [ + self::DATABASE_ENGINE_UNSPECIFIED => 'DATABASE_ENGINE_UNSPECIFIED', + self::ALL_SUPPORTED_DATABASE_ENGINES => 'ALL_SUPPORTED_DATABASE_ENGINES', + self::MYSQL => 'MYSQL', + self::POSTGRES => 'POSTGRES', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(DatabaseEngine::class, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlConditions_DatabaseEngine::class); + diff --git a/Dlp/src/V2/DiscoveryCloudSqlConditions/DatabaseResourceType.php b/Dlp/src/V2/DiscoveryCloudSqlConditions/DatabaseResourceType.php new file mode 100644 index 000000000000..50969361416d --- /dev/null +++ b/Dlp/src/V2/DiscoveryCloudSqlConditions/DatabaseResourceType.php @@ -0,0 +1,64 @@ +google.privacy.dlp.v2.DiscoveryCloudSqlConditions.DatabaseResourceType + */ +class DatabaseResourceType +{ + /** + * Unused. + * + * Generated from protobuf enum DATABASE_RESOURCE_TYPE_UNSPECIFIED = 0; + */ + const DATABASE_RESOURCE_TYPE_UNSPECIFIED = 0; + /** + * Includes database resource types that become supported at a later time. + * + * Generated from protobuf enum DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES = 1; + */ + const DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES = 1; + /** + * Tables. + * + * Generated from protobuf enum DATABASE_RESOURCE_TYPE_TABLE = 2; + */ + const DATABASE_RESOURCE_TYPE_TABLE = 2; + + private static $valueToName = [ + self::DATABASE_RESOURCE_TYPE_UNSPECIFIED => 'DATABASE_RESOURCE_TYPE_UNSPECIFIED', + self::DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES => 'DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES', + self::DATABASE_RESOURCE_TYPE_TABLE => 'DATABASE_RESOURCE_TYPE_TABLE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(DatabaseResourceType::class, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlConditions_DatabaseResourceType::class); + diff --git a/Dlp/src/V2/DiscoveryCloudSqlFilter.php b/Dlp/src/V2/DiscoveryCloudSqlFilter.php new file mode 100644 index 000000000000..c2d34c2f8649 --- /dev/null +++ b/Dlp/src/V2/DiscoveryCloudSqlFilter.php @@ -0,0 +1,155 @@ +google.privacy.dlp.v2.DiscoveryCloudSqlFilter + */ +class DiscoveryCloudSqlFilter extends \Google\Protobuf\Internal\Message +{ + protected $filter; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Dlp\V2\DatabaseResourceCollection $collection + * A specific set of database resources for this filter to apply to. + * @type \Google\Cloud\Dlp\V2\AllOtherDatabaseResources $others + * Catch-all. This should always be the last target in the list because + * anything above it will apply first. Should only appear once in a + * configuration. If none is specified, a default one will be added + * automatically. + * @type \Google\Cloud\Dlp\V2\DatabaseResourceReference $database_resource_reference + * The database resource to scan. Targets including this can only include + * one target (the target with this database resource reference). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * A specific set of database resources for this filter to apply to. + * + * Generated from protobuf field .google.privacy.dlp.v2.DatabaseResourceCollection collection = 1; + * @return \Google\Cloud\Dlp\V2\DatabaseResourceCollection|null + */ + public function getCollection() + { + return $this->readOneof(1); + } + + public function hasCollection() + { + return $this->hasOneof(1); + } + + /** + * A specific set of database resources for this filter to apply to. + * + * Generated from protobuf field .google.privacy.dlp.v2.DatabaseResourceCollection collection = 1; + * @param \Google\Cloud\Dlp\V2\DatabaseResourceCollection $var + * @return $this + */ + public function setCollection($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\DatabaseResourceCollection::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Catch-all. This should always be the last target in the list because + * anything above it will apply first. Should only appear once in a + * configuration. If none is specified, a default one will be added + * automatically. + * + * Generated from protobuf field .google.privacy.dlp.v2.AllOtherDatabaseResources others = 2; + * @return \Google\Cloud\Dlp\V2\AllOtherDatabaseResources|null + */ + public function getOthers() + { + return $this->readOneof(2); + } + + public function hasOthers() + { + return $this->hasOneof(2); + } + + /** + * Catch-all. This should always be the last target in the list because + * anything above it will apply first. Should only appear once in a + * configuration. If none is specified, a default one will be added + * automatically. + * + * Generated from protobuf field .google.privacy.dlp.v2.AllOtherDatabaseResources others = 2; + * @param \Google\Cloud\Dlp\V2\AllOtherDatabaseResources $var + * @return $this + */ + public function setOthers($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\AllOtherDatabaseResources::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * The database resource to scan. Targets including this can only include + * one target (the target with this database resource reference). + * + * Generated from protobuf field .google.privacy.dlp.v2.DatabaseResourceReference database_resource_reference = 3; + * @return \Google\Cloud\Dlp\V2\DatabaseResourceReference|null + */ + public function getDatabaseResourceReference() + { + return $this->readOneof(3); + } + + public function hasDatabaseResourceReference() + { + return $this->hasOneof(3); + } + + /** + * The database resource to scan. Targets including this can only include + * one target (the target with this database resource reference). + * + * Generated from protobuf field .google.privacy.dlp.v2.DatabaseResourceReference database_resource_reference = 3; + * @param \Google\Cloud\Dlp\V2\DatabaseResourceReference $var + * @return $this + */ + public function setDatabaseResourceReference($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\DatabaseResourceReference::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * @return string + */ + public function getFilter() + { + return $this->whichOneof("filter"); + } + +} + diff --git a/Dlp/src/V2/DiscoveryCloudSqlGenerationCadence.php b/Dlp/src/V2/DiscoveryCloudSqlGenerationCadence.php new file mode 100644 index 000000000000..a021a2f9936e --- /dev/null +++ b/Dlp/src/V2/DiscoveryCloudSqlGenerationCadence.php @@ -0,0 +1,125 @@ +google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence + */ +class DiscoveryCloudSqlGenerationCadence extends \Google\Protobuf\Internal\Message +{ + /** + * When to reprofile if the schema has changed. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence.SchemaModifiedCadence schema_modified_cadence = 1; + */ + private $schema_modified_cadence = null; + /** + * Data changes (non-schema changes) in Cloud SQL tables can't trigger + * reprofiling. If you set this field, profiles are refreshed at this + * frequency regardless of whether the underlying tables have changes. + * Defaults to never. + * + * Generated from protobuf field .google.privacy.dlp.v2.DataProfileUpdateFrequency refresh_frequency = 2; + */ + private $refresh_frequency = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence\SchemaModifiedCadence $schema_modified_cadence + * When to reprofile if the schema has changed. + * @type int $refresh_frequency + * Data changes (non-schema changes) in Cloud SQL tables can't trigger + * reprofiling. If you set this field, profiles are refreshed at this + * frequency regardless of whether the underlying tables have changes. + * Defaults to never. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * When to reprofile if the schema has changed. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence.SchemaModifiedCadence schema_modified_cadence = 1; + * @return \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence\SchemaModifiedCadence|null + */ + public function getSchemaModifiedCadence() + { + return $this->schema_modified_cadence; + } + + public function hasSchemaModifiedCadence() + { + return isset($this->schema_modified_cadence); + } + + public function clearSchemaModifiedCadence() + { + unset($this->schema_modified_cadence); + } + + /** + * When to reprofile if the schema has changed. + * + * Generated from protobuf field .google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence.SchemaModifiedCadence schema_modified_cadence = 1; + * @param \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence\SchemaModifiedCadence $var + * @return $this + */ + public function setSchemaModifiedCadence($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence\SchemaModifiedCadence::class); + $this->schema_modified_cadence = $var; + + return $this; + } + + /** + * Data changes (non-schema changes) in Cloud SQL tables can't trigger + * reprofiling. If you set this field, profiles are refreshed at this + * frequency regardless of whether the underlying tables have changes. + * Defaults to never. + * + * Generated from protobuf field .google.privacy.dlp.v2.DataProfileUpdateFrequency refresh_frequency = 2; + * @return int + */ + public function getRefreshFrequency() + { + return $this->refresh_frequency; + } + + /** + * Data changes (non-schema changes) in Cloud SQL tables can't trigger + * reprofiling. If you set this field, profiles are refreshed at this + * frequency regardless of whether the underlying tables have changes. + * Defaults to never. + * + * Generated from protobuf field .google.privacy.dlp.v2.DataProfileUpdateFrequency refresh_frequency = 2; + * @param int $var + * @return $this + */ + public function setRefreshFrequency($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Dlp\V2\DataProfileUpdateFrequency::class); + $this->refresh_frequency = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/DiscoveryCloudSqlGenerationCadence/SchemaModifiedCadence.php b/Dlp/src/V2/DiscoveryCloudSqlGenerationCadence/SchemaModifiedCadence.php new file mode 100644 index 000000000000..cda43bdbfc31 --- /dev/null +++ b/Dlp/src/V2/DiscoveryCloudSqlGenerationCadence/SchemaModifiedCadence.php @@ -0,0 +1,112 @@ +google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence.SchemaModifiedCadence + */ +class SchemaModifiedCadence extends \Google\Protobuf\Internal\Message +{ + /** + * The types of schema modifications to consider. + * Defaults to NEW_COLUMNS. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence.SchemaModifiedCadence.CloudSqlSchemaModification types = 1; + */ + private $types; + /** + * Frequency to regenerate data profiles when the schema is modified. + * Defaults to monthly. + * + * Generated from protobuf field .google.privacy.dlp.v2.DataProfileUpdateFrequency frequency = 2; + */ + private $frequency = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $types + * The types of schema modifications to consider. + * Defaults to NEW_COLUMNS. + * @type int $frequency + * Frequency to regenerate data profiles when the schema is modified. + * Defaults to monthly. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * The types of schema modifications to consider. + * Defaults to NEW_COLUMNS. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence.SchemaModifiedCadence.CloudSqlSchemaModification types = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getTypes() + { + return $this->types; + } + + /** + * The types of schema modifications to consider. + * Defaults to NEW_COLUMNS. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence.SchemaModifiedCadence.CloudSqlSchemaModification types = 1; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setTypes($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence\SchemaModifiedCadence\CloudSqlSchemaModification::class); + $this->types = $arr; + + return $this; + } + + /** + * Frequency to regenerate data profiles when the schema is modified. + * Defaults to monthly. + * + * Generated from protobuf field .google.privacy.dlp.v2.DataProfileUpdateFrequency frequency = 2; + * @return int + */ + public function getFrequency() + { + return $this->frequency; + } + + /** + * Frequency to regenerate data profiles when the schema is modified. + * Defaults to monthly. + * + * Generated from protobuf field .google.privacy.dlp.v2.DataProfileUpdateFrequency frequency = 2; + * @param int $var + * @return $this + */ + public function setFrequency($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Dlp\V2\DataProfileUpdateFrequency::class); + $this->frequency = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(SchemaModifiedCadence::class, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence_SchemaModifiedCadence::class); + diff --git a/Dlp/src/V2/DiscoveryCloudSqlGenerationCadence/SchemaModifiedCadence/CloudSqlSchemaModification.php b/Dlp/src/V2/DiscoveryCloudSqlGenerationCadence/SchemaModifiedCadence/CloudSqlSchemaModification.php new file mode 100644 index 000000000000..4795c5accc69 --- /dev/null +++ b/Dlp/src/V2/DiscoveryCloudSqlGenerationCadence/SchemaModifiedCadence/CloudSqlSchemaModification.php @@ -0,0 +1,64 @@ +google.privacy.dlp.v2.DiscoveryCloudSqlGenerationCadence.SchemaModifiedCadence.CloudSqlSchemaModification + */ +class CloudSqlSchemaModification +{ + /** + * Unused. + * + * Generated from protobuf enum SQL_SCHEMA_MODIFICATION_UNSPECIFIED = 0; + */ + const SQL_SCHEMA_MODIFICATION_UNSPECIFIED = 0; + /** + * New columns has appeared. + * + * Generated from protobuf enum NEW_COLUMNS = 1; + */ + const NEW_COLUMNS = 1; + /** + * Columns have been removed from the table. + * + * Generated from protobuf enum REMOVED_COLUMNS = 2; + */ + const REMOVED_COLUMNS = 2; + + private static $valueToName = [ + self::SQL_SCHEMA_MODIFICATION_UNSPECIFIED => 'SQL_SCHEMA_MODIFICATION_UNSPECIFIED', + self::NEW_COLUMNS => 'NEW_COLUMNS', + self::REMOVED_COLUMNS => 'REMOVED_COLUMNS', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(CloudSqlSchemaModification::class, \Google\Cloud\Dlp\V2\DiscoveryCloudSqlGenerationCadence_SchemaModifiedCadence_CloudSqlSchemaModification::class); + diff --git a/Dlp/src/V2/DiscoveryTarget.php b/Dlp/src/V2/DiscoveryTarget.php index b1231e0b30ad..2d370f3c3907 100644 --- a/Dlp/src/V2/DiscoveryTarget.php +++ b/Dlp/src/V2/DiscoveryTarget.php @@ -26,6 +26,9 @@ class DiscoveryTarget extends \Google\Protobuf\Internal\Message * @type \Google\Cloud\Dlp\V2\BigQueryDiscoveryTarget $big_query_target * BigQuery target for Discovery. The first target to match a table will be * the one applied. + * @type \Google\Cloud\Dlp\V2\CloudSqlDiscoveryTarget $cloud_sql_target + * Cloud SQL target for Discovery. The first target to match a table will be + * the one applied. * } */ public function __construct($data = NULL) { @@ -66,6 +69,39 @@ public function setBigQueryTarget($var) return $this; } + /** + * Cloud SQL target for Discovery. The first target to match a table will be + * the one applied. + * + * Generated from protobuf field .google.privacy.dlp.v2.CloudSqlDiscoveryTarget cloud_sql_target = 2; + * @return \Google\Cloud\Dlp\V2\CloudSqlDiscoveryTarget|null + */ + public function getCloudSqlTarget() + { + return $this->readOneof(2); + } + + public function hasCloudSqlTarget() + { + return $this->hasOneof(2); + } + + /** + * Cloud SQL target for Discovery. The first target to match a table will be + * the one applied. + * + * Generated from protobuf field .google.privacy.dlp.v2.CloudSqlDiscoveryTarget cloud_sql_target = 2; + * @param \Google\Cloud\Dlp\V2\CloudSqlDiscoveryTarget $var + * @return $this + */ + public function setCloudSqlTarget($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CloudSqlDiscoveryTarget::class); + $this->writeOneof(2, $var); + + return $this; + } + /** * @return string */ diff --git a/Dlp/src/V2/Gapic/DlpServiceGapicClient.php b/Dlp/src/V2/Gapic/DlpServiceGapicClient.php index 5e7c3648823e..fbe3b215eec3 100644 --- a/Dlp/src/V2/Gapic/DlpServiceGapicClient.php +++ b/Dlp/src/V2/Gapic/DlpServiceGapicClient.php @@ -37,7 +37,9 @@ use Google\Cloud\Dlp\V2\ByteContentItem; use Google\Cloud\Dlp\V2\CancelDlpJobRequest; use Google\Cloud\Dlp\V2\ColumnDataProfile; +use Google\Cloud\Dlp\V2\Connection; use Google\Cloud\Dlp\V2\ContentItem; +use Google\Cloud\Dlp\V2\CreateConnectionRequest; use Google\Cloud\Dlp\V2\CreateDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\CreateDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\CreateDlpJobRequest; @@ -48,17 +50,20 @@ use Google\Cloud\Dlp\V2\DeidentifyContentRequest; use Google\Cloud\Dlp\V2\DeidentifyContentResponse; use Google\Cloud\Dlp\V2\DeidentifyTemplate; +use Google\Cloud\Dlp\V2\DeleteConnectionRequest; use Google\Cloud\Dlp\V2\DeleteDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\DeleteDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\DeleteDlpJobRequest; use Google\Cloud\Dlp\V2\DeleteInspectTemplateRequest; use Google\Cloud\Dlp\V2\DeleteJobTriggerRequest; use Google\Cloud\Dlp\V2\DeleteStoredInfoTypeRequest; +use Google\Cloud\Dlp\V2\DeleteTableDataProfileRequest; use Google\Cloud\Dlp\V2\DiscoveryConfig; use Google\Cloud\Dlp\V2\DlpJob; use Google\Cloud\Dlp\V2\DlpJobType; use Google\Cloud\Dlp\V2\FinishDlpJobRequest; use Google\Cloud\Dlp\V2\GetColumnDataProfileRequest; +use Google\Cloud\Dlp\V2\GetConnectionRequest; use Google\Cloud\Dlp\V2\GetDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\GetDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\GetDlpJobRequest; @@ -79,6 +84,8 @@ use Google\Cloud\Dlp\V2\JobTrigger; use Google\Cloud\Dlp\V2\ListColumnDataProfilesRequest; use Google\Cloud\Dlp\V2\ListColumnDataProfilesResponse; +use Google\Cloud\Dlp\V2\ListConnectionsRequest; +use Google\Cloud\Dlp\V2\ListConnectionsResponse; use Google\Cloud\Dlp\V2\ListDeidentifyTemplatesRequest; use Google\Cloud\Dlp\V2\ListDeidentifyTemplatesResponse; use Google\Cloud\Dlp\V2\ListDiscoveryConfigsRequest; @@ -104,9 +111,12 @@ use Google\Cloud\Dlp\V2\ReidentifyContentRequest; use Google\Cloud\Dlp\V2\ReidentifyContentResponse; use Google\Cloud\Dlp\V2\RiskAnalysisJobConfig; +use Google\Cloud\Dlp\V2\SearchConnectionsRequest; +use Google\Cloud\Dlp\V2\SearchConnectionsResponse; use Google\Cloud\Dlp\V2\StoredInfoType; use Google\Cloud\Dlp\V2\StoredInfoTypeConfig; use Google\Cloud\Dlp\V2\TableDataProfile; +use Google\Cloud\Dlp\V2\UpdateConnectionRequest; use Google\Cloud\Dlp\V2\UpdateDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\UpdateDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\UpdateInspectTemplateRequest; @@ -176,6 +186,8 @@ class DlpServiceGapicClient private static $columnDataProfileNameTemplate; + private static $connectionNameTemplate; + private static $deidentifyTemplateNameTemplate; private static $discoveryConfigNameTemplate; @@ -282,6 +294,17 @@ private static function getColumnDataProfileNameTemplate() return self::$columnDataProfileNameTemplate; } + private static function getConnectionNameTemplate() + { + if (self::$connectionNameTemplate == null) { + self::$connectionNameTemplate = new PathTemplate( + 'projects/{project}/locations/{location}/connections/{connection}' + ); + } + + return self::$connectionNameTemplate; + } + private static function getDeidentifyTemplateNameTemplate() { if (self::$deidentifyTemplateNameTemplate == null) { @@ -659,6 +682,7 @@ private static function getPathTemplateMap() if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ 'columnDataProfile' => self::getColumnDataProfileNameTemplate(), + 'connection' => self::getConnectionNameTemplate(), 'deidentifyTemplate' => self::getDeidentifyTemplateNameTemplate(), 'discoveryConfig' => self::getDiscoveryConfigNameTemplate(), 'dlpJob' => self::getDlpJobNameTemplate(), @@ -721,6 +745,25 @@ public static function columnDataProfileName( ]); } + /** + * Formats a string containing the fully-qualified path to represent a connection + * resource. + * + * @param string $project + * @param string $location + * @param string $connection + * + * @return string The formatted connection resource. + */ + public static function connectionName($project, $location, $connection) + { + return self::getConnectionNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'connection' => $connection, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a * deidentify_template resource. @@ -1413,6 +1456,7 @@ public static function tableDataProfileName( * The following name formats are supported: * Template: Pattern * - columnDataProfile: organizations/{organization}/locations/{location}/columnDataProfiles/{column_data_profile} + * - connection: projects/{project}/locations/{location}/connections/{connection} * - deidentifyTemplate: organizations/{organization}/deidentifyTemplates/{deidentify_template} * - discoveryConfig: projects/{project}/locations/{location}/discoveryConfigs/{discovery_config} * - dlpJob: projects/{project}/dlpJobs/{dlp_job} @@ -1650,6 +1694,61 @@ public function cancelDlpJob($name, array $optionalArgs = []) )->wait(); } + /** + * Create a Connection to an external data source. + * + * Sample code: + * ``` + * $dlpServiceClient = new DlpServiceClient(); + * try { + * $formattedParent = $dlpServiceClient->locationName('[PROJECT]', '[LOCATION]'); + * $connection = new Connection(); + * $response = $dlpServiceClient->createConnection($formattedParent, $connection); + * } finally { + * $dlpServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. Parent resource name in the format: + * `projects/{project}/locations/{location}`. + * @param Connection $connection Required. The connection resource. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Dlp\V2\Connection + * + * @throws ApiException if the remote call fails + */ + public function createConnection( + $parent, + $connection, + array $optionalArgs = [] + ) { + $request = new CreateConnectionRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setConnection($connection); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'CreateConnection', + Connection::class, + $optionalArgs, + $request + )->wait(); + } + /** * Creates a DeidentifyTemplate for reusing frequently used configuration * for de-identifying content, images, and storage. @@ -2320,6 +2419,53 @@ public function deidentifyContent(array $optionalArgs = []) )->wait(); } + /** + * Delete a Connection. + * + * Sample code: + * ``` + * $dlpServiceClient = new DlpServiceClient(); + * try { + * $formattedName = $dlpServiceClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + * $dlpServiceClient->deleteConnection($formattedName); + * } finally { + * $dlpServiceClient->close(); + * } + * ``` + * + * @param string $name Required. Resource name of the Connection to be deleted, in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteConnection($name, array $optionalArgs = []) + { + $request = new DeleteConnectionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'DeleteConnection', + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); + } + /** * Deletes a DeidentifyTemplate. * See @@ -2624,6 +2770,53 @@ public function deleteStoredInfoType($name, array $optionalArgs = []) )->wait(); } + /** + * Delete a TableDataProfile. Will not prevent the profile from being + * regenerated if the table is still included in a discovery configuration. + * + * Sample code: + * ``` + * $dlpServiceClient = new DlpServiceClient(); + * try { + * $formattedName = $dlpServiceClient->tableDataProfileName('[ORGANIZATION]', '[LOCATION]', '[TABLE_DATA_PROFILE]'); + * $dlpServiceClient->deleteTableDataProfile($formattedName); + * } finally { + * $dlpServiceClient->close(); + * } + * ``` + * + * @param string $name Required. Resource name of the table data profile. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteTableDataProfile($name, array $optionalArgs = []) + { + $request = new DeleteTableDataProfileRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'DeleteTableDataProfile', + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); + } + /** * Finish a running hybrid DlpJob. Triggers the finalization steps and running * of any enabled actions that have not yet run. @@ -2720,6 +2913,55 @@ public function getColumnDataProfile($name, array $optionalArgs = []) )->wait(); } + /** + * Get a Connection by name. + * + * Sample code: + * ``` + * $dlpServiceClient = new DlpServiceClient(); + * try { + * $formattedName = $dlpServiceClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + * $response = $dlpServiceClient->getConnection($formattedName); + * } finally { + * $dlpServiceClient->close(); + * } + * ``` + * + * @param string $name Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Dlp\V2\Connection + * + * @throws ApiException if the remote call fails + */ + public function getConnection($name, array $optionalArgs = []) + { + $request = new GetConnectionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'GetConnection', + Connection::class, + $optionalArgs, + $request + )->wait(); + } + /** * Gets a DeidentifyTemplate. * See @@ -3353,7 +3595,7 @@ public function inspectContent(array $optionalArgs = []) } /** - * Lists data profiles for an organization. + * Lists column data profiles for an organization. * * Sample code: * ``` @@ -3490,6 +3732,91 @@ public function listColumnDataProfiles($parent, array $optionalArgs = []) ); } + /** + * Lists Connections in a parent. + * + * Sample code: + * ``` + * $dlpServiceClient = new DlpServiceClient(); + * try { + * $formattedParent = $dlpServiceClient->locationName('[PROJECT]', '[LOCATION]'); + * // Iterate over pages of elements + * $pagedResponse = $dlpServiceClient->listConnections($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $dlpServiceClient->listConnections($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $dlpServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. Parent name, for example: + * `projects/project-id/locations/global`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type string $filter + * Optional. * Supported fields/values + * - `state` - MISSING|AVAILABLE|ERROR + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listConnections($parent, array $optionalArgs = []) + { + $request = new ListConnectionsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->getPagedListResponse( + 'ListConnections', + $optionalArgs, + ListConnectionsResponse::class, + $request + ); + } + /** * Lists DeidentifyTemplates. * See @@ -4237,7 +4564,7 @@ public function listJobTriggers($parent, array $optionalArgs = []) } /** - * Lists data profiles for an organization. + * Lists project data profiles for an organization. * * Sample code: * ``` @@ -4287,7 +4614,7 @@ public function listJobTriggers($parent, array $optionalArgs = []) * * Supported fields are: * - * - `project_id`: GCP project ID + * - `project_id`: Google Cloud project ID * - `sensitivity_level`: How sensitive the data in a project is, at most. * - `data_risk_level`: How much risk is associated with this data. * - `profile_last_generated`: When the profile was last updated in epoch @@ -4481,7 +4808,7 @@ public function listStoredInfoTypes($parent, array $optionalArgs = []) } /** - * Lists data profiles for an organization. + * Lists table data profiles for an organization. * * Sample code: * ``` @@ -4534,7 +4861,7 @@ public function listStoredInfoTypes($parent, array $optionalArgs = []) * * Supported fields are: * - * - `project_id`: The GCP project ID. + * - `project_id`: The Google Cloud project ID. * - `dataset_id`: The ID of a BigQuery dataset. * - `table_id`: The ID of a BigQuery table. * - `sensitivity_level`: How sensitive the data in a table is, at most. @@ -4554,7 +4881,7 @@ public function listStoredInfoTypes($parent, array $optionalArgs = []) * sequence of restrictions implicitly uses `AND`. * * A restriction has the form of `{field} {operator} {value}`. * * Supported fields/values: - * - `project_id` - The GCP project ID. + * - `project_id` - The Google Cloud project ID. * - `dataset_id` - The BigQuery dataset ID. * - `table_id` - The ID of the BigQuery table. * - `sensitivity_level` - HIGH|MODERATE|LOW @@ -4849,6 +5176,152 @@ public function reidentifyContent($parent, array $optionalArgs = []) )->wait(); } + /** + * Searches for Connections in a parent. + * + * Sample code: + * ``` + * $dlpServiceClient = new DlpServiceClient(); + * try { + * $formattedParent = $dlpServiceClient->locationName('[PROJECT]', '[LOCATION]'); + * // Iterate over pages of elements + * $pagedResponse = $dlpServiceClient->searchConnections($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $dlpServiceClient->searchConnections($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $dlpServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. Parent name, typically an organization, without location. + * For example: `organizations/12345678`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type string $filter + * Optional. * Supported fields/values + * - `state` - MISSING|AVAILABLE|ERROR + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function searchConnections($parent, array $optionalArgs = []) + { + $request = new SearchConnectionsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->getPagedListResponse( + 'SearchConnections', + $optionalArgs, + SearchConnectionsResponse::class, + $request + ); + } + + /** + * Update a Connection. + * + * Sample code: + * ``` + * $dlpServiceClient = new DlpServiceClient(); + * try { + * $formattedName = $dlpServiceClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + * $connection = new Connection(); + * $response = $dlpServiceClient->updateConnection($formattedName, $connection); + * } finally { + * $dlpServiceClient->close(); + * } + * ``` + * + * @param string $name Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * @param Connection $connection Required. The connection with new values for the relevant fields. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * Optional. Mask to control which fields get updated. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Dlp\V2\Connection + * + * @throws ApiException if the remote call fails + */ + public function updateConnection( + $name, + $connection, + array $optionalArgs = [] + ) { + $request = new UpdateConnectionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $request->setConnection($connection); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'UpdateConnection', + Connection::class, + $optionalArgs, + $request + )->wait(); + } + /** * Updates the DeidentifyTemplate. * See diff --git a/Dlp/src/V2/GetConnectionRequest.php b/Dlp/src/V2/GetConnectionRequest.php new file mode 100644 index 000000000000..fc462f1ea7a2 --- /dev/null +++ b/Dlp/src/V2/GetConnectionRequest.php @@ -0,0 +1,86 @@ +google.privacy.dlp.v2.GetConnectionRequest + */ +class GetConnectionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * @param string $name Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. Please see + * {@see DlpServiceClient::connectionName()} for help formatting this field. + * + * @return \Google\Cloud\Dlp\V2\GetConnectionRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/InfoTypeCategory/LocationCategory.php b/Dlp/src/V2/InfoTypeCategory/LocationCategory.php index 20769afaf042..e8f10a77b825 100644 --- a/Dlp/src/V2/InfoTypeCategory/LocationCategory.php +++ b/Dlp/src/V2/InfoTypeCategory/LocationCategory.php @@ -147,6 +147,12 @@ class LocationCategory * Generated from protobuf enum JAPAN = 20; */ const JAPAN = 20; + /** + * The infoType is typically used in Kazakhstan. + * + * Generated from protobuf enum KAZAKHSTAN = 47; + */ + const KAZAKHSTAN = 47; /** * The infoType is typically used in Korea. * @@ -201,6 +207,12 @@ class LocationCategory * Generated from protobuf enum PORTUGAL = 28; */ const PORTUGAL = 28; + /** + * The infoType is typically used in Russia. + * + * Generated from protobuf enum RUSSIA = 44; + */ + const RUSSIA = 44; /** * The infoType is typically used in Singapore. * @@ -249,6 +261,12 @@ class LocationCategory * Generated from protobuf enum TURKEY = 35; */ const TURKEY = 35; + /** + * The infoType is typically used in Ukraine. + * + * Generated from protobuf enum UKRAINE = 45; + */ + const UKRAINE = 45; /** * The infoType is typically used in the United Kingdom. * @@ -267,6 +285,12 @@ class LocationCategory * Generated from protobuf enum URUGUAY = 38; */ const URUGUAY = 38; + /** + * The infoType is typically used in Uzbekistan. + * + * Generated from protobuf enum UZBEKISTAN = 46; + */ + const UZBEKISTAN = 46; /** * The infoType is typically used in Venezuela. * @@ -303,6 +327,7 @@ class LocationCategory self::ISRAEL => 'ISRAEL', self::ITALY => 'ITALY', self::JAPAN => 'JAPAN', + self::KAZAKHSTAN => 'KAZAKHSTAN', self::KOREA => 'KOREA', self::MEXICO => 'MEXICO', self::THE_NETHERLANDS => 'THE_NETHERLANDS', @@ -312,6 +337,7 @@ class LocationCategory self::PERU => 'PERU', self::POLAND => 'POLAND', self::PORTUGAL => 'PORTUGAL', + self::RUSSIA => 'RUSSIA', self::SINGAPORE => 'SINGAPORE', self::SOUTH_AFRICA => 'SOUTH_AFRICA', self::SPAIN => 'SPAIN', @@ -320,9 +346,11 @@ class LocationCategory self::TAIWAN => 'TAIWAN', self::THAILAND => 'THAILAND', self::TURKEY => 'TURKEY', + self::UKRAINE => 'UKRAINE', self::UNITED_KINGDOM => 'UNITED_KINGDOM', self::UNITED_STATES => 'UNITED_STATES', self::URUGUAY => 'URUGUAY', + self::UZBEKISTAN => 'UZBEKISTAN', self::VENEZUELA => 'VENEZUELA', self::INTERNAL => 'INTERNAL', ]; diff --git a/Dlp/src/V2/InspectDataSourceDetails/Result.php b/Dlp/src/V2/InspectDataSourceDetails/Result.php index 2d16ce81fdd8..8082329f0d79 100644 --- a/Dlp/src/V2/InspectDataSourceDetails/Result.php +++ b/Dlp/src/V2/InspectDataSourceDetails/Result.php @@ -34,6 +34,13 @@ class Result extends \Google\Protobuf\Internal\Message * Generated from protobuf field repeated .google.privacy.dlp.v2.InfoTypeStats info_type_stats = 3; */ private $info_type_stats; + /** + * Number of rows scanned post sampling and time filtering (Applicable for + * row based stores such as BigQuery). + * + * Generated from protobuf field int64 num_rows_processed = 5; + */ + private $num_rows_processed = 0; /** * Statistics related to the processing of hybrid inspect. * @@ -54,6 +61,9 @@ class Result extends \Google\Protobuf\Internal\Message * @type array<\Google\Cloud\Dlp\V2\InfoTypeStats>|\Google\Protobuf\Internal\RepeatedField $info_type_stats * Statistics of how many instances of each info type were found during * inspect job. + * @type int|string $num_rows_processed + * Number of rows scanned post sampling and time filtering (Applicable for + * row based stores such as BigQuery). * @type \Google\Cloud\Dlp\V2\HybridInspectStatistics $hybrid_stats * Statistics related to the processing of hybrid inspect. * } @@ -143,6 +153,34 @@ public function setInfoTypeStats($var) return $this; } + /** + * Number of rows scanned post sampling and time filtering (Applicable for + * row based stores such as BigQuery). + * + * Generated from protobuf field int64 num_rows_processed = 5; + * @return int|string + */ + public function getNumRowsProcessed() + { + return $this->num_rows_processed; + } + + /** + * Number of rows scanned post sampling and time filtering (Applicable for + * row based stores such as BigQuery). + * + * Generated from protobuf field int64 num_rows_processed = 5; + * @param int|string $var + * @return $this + */ + public function setNumRowsProcessed($var) + { + GPBUtil::checkInt64($var); + $this->num_rows_processed = $var; + + return $this; + } + /** * Statistics related to the processing of hybrid inspect. * diff --git a/Dlp/src/V2/JobTrigger.php b/Dlp/src/V2/JobTrigger.php index 3c0eff6a6e34..7311b52bd590 100644 --- a/Dlp/src/V2/JobTrigger.php +++ b/Dlp/src/V2/JobTrigger.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\GPBUtil; /** - * Contains a configuration to make dlp api calls on a repeating basis. + * Contains a configuration to make api calls on a repeating basis. * See * https://cloud.google.com/sensitive-data-protection/docs/concepts-job-triggers * to learn more. diff --git a/Dlp/src/V2/ListConnectionsRequest.php b/Dlp/src/V2/ListConnectionsRequest.php new file mode 100644 index 000000000000..757b645d927c --- /dev/null +++ b/Dlp/src/V2/ListConnectionsRequest.php @@ -0,0 +1,196 @@ +google.privacy.dlp.v2.ListConnectionsRequest + */ +class ListConnectionsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Parent name, for example: + * `projects/project-id/locations/global`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Optional. Number of results per page, max 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + /** + * Optional. Page token from a previous page to return the next set of + * results. If set, all other request fields must match the original request. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + /** + * Optional. * Supported fields/values + * - `state` - MISSING|AVAILABLE|ERROR + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $filter = ''; + + /** + * @param string $parent Required. Parent name, for example: + * `projects/project-id/locations/global`. Please see + * {@see DlpServiceClient::locationName()} for help formatting this field. + * + * @return \Google\Cloud\Dlp\V2\ListConnectionsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. Parent name, for example: + * `projects/project-id/locations/global`. + * @type int $page_size + * Optional. Number of results per page, max 1000. + * @type string $page_token + * Optional. Page token from a previous page to return the next set of + * results. If set, all other request fields must match the original request. + * @type string $filter + * Optional. * Supported fields/values + * - `state` - MISSING|AVAILABLE|ERROR + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Required. Parent name, for example: + * `projects/project-id/locations/global`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. Parent name, for example: + * `projects/project-id/locations/global`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. Number of results per page, max 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. Number of results per page, max 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Optional. Page token from a previous page to return the next set of + * results. If set, all other request fields must match the original request. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. Page token from a previous page to return the next set of + * results. If set, all other request fields must match the original request. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * Optional. * Supported fields/values + * - `state` - MISSING|AVAILABLE|ERROR + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Optional. * Supported fields/values + * - `state` - MISSING|AVAILABLE|ERROR + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/ListConnectionsResponse.php b/Dlp/src/V2/ListConnectionsResponse.php new file mode 100644 index 000000000000..4c13dd6c2506 --- /dev/null +++ b/Dlp/src/V2/ListConnectionsResponse.php @@ -0,0 +1,105 @@ +google.privacy.dlp.v2.ListConnectionsResponse + */ +class ListConnectionsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * List of connections. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.Connection connections = 1; + */ + private $connections; + /** + * Token to retrieve the next page of results. An empty value means there are + * no more results. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Dlp\V2\Connection>|\Google\Protobuf\Internal\RepeatedField $connections + * List of connections. + * @type string $next_page_token + * Token to retrieve the next page of results. An empty value means there are + * no more results. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * List of connections. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.Connection connections = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getConnections() + { + return $this->connections; + } + + /** + * List of connections. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.Connection connections = 1; + * @param array<\Google\Cloud\Dlp\V2\Connection>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setConnections($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\Connection::class); + $this->connections = $arr; + + return $this; + } + + /** + * Token to retrieve the next page of results. An empty value means there are + * no more results. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * Token to retrieve the next page of results. An empty value means there are + * no more results. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/ListProjectDataProfilesRequest.php b/Dlp/src/V2/ListProjectDataProfilesRequest.php index 605a6205ec87..8e9ca36d5673 100644 --- a/Dlp/src/V2/ListProjectDataProfilesRequest.php +++ b/Dlp/src/V2/ListProjectDataProfilesRequest.php @@ -43,7 +43,7 @@ class ListProjectDataProfilesRequest extends \Google\Protobuf\Internal\Message * * `project_id` * * `sensitivity_level desc` * Supported fields are: - * - `project_id`: GCP project ID + * - `project_id`: Google Cloud project ID * - `sensitivity_level`: How sensitive the data in a project is, at most. * - `data_risk_level`: How much risk is associated with this data. * - `profile_last_generated`: When the profile was last updated in epoch @@ -110,7 +110,7 @@ public static function build(string $parent): self * * `project_id` * * `sensitivity_level desc` * Supported fields are: - * - `project_id`: GCP project ID + * - `project_id`: Google Cloud project ID * - `sensitivity_level`: How sensitive the data in a project is, at most. * - `data_risk_level`: How much risk is associated with this data. * - `profile_last_generated`: When the profile was last updated in epoch @@ -228,7 +228,7 @@ public function setPageSize($var) * * `project_id` * * `sensitivity_level desc` * Supported fields are: - * - `project_id`: GCP project ID + * - `project_id`: Google Cloud project ID * - `sensitivity_level`: How sensitive the data in a project is, at most. * - `data_risk_level`: How much risk is associated with this data. * - `profile_last_generated`: When the profile was last updated in epoch @@ -251,7 +251,7 @@ public function getOrderBy() * * `project_id` * * `sensitivity_level desc` * Supported fields are: - * - `project_id`: GCP project ID + * - `project_id`: Google Cloud project ID * - `sensitivity_level`: How sensitive the data in a project is, at most. * - `data_risk_level`: How much risk is associated with this data. * - `profile_last_generated`: When the profile was last updated in epoch diff --git a/Dlp/src/V2/ListTableDataProfilesRequest.php b/Dlp/src/V2/ListTableDataProfilesRequest.php index 4091b09ffe6c..6d12a494d45f 100644 --- a/Dlp/src/V2/ListTableDataProfilesRequest.php +++ b/Dlp/src/V2/ListTableDataProfilesRequest.php @@ -46,7 +46,7 @@ class ListTableDataProfilesRequest extends \Google\Protobuf\Internal\Message * * `table_id` * * `sensitivity_level desc` * Supported fields are: - * - `project_id`: The GCP project ID. + * - `project_id`: The Google Cloud project ID. * - `dataset_id`: The ID of a BigQuery dataset. * - `table_id`: The ID of a BigQuery table. * - `sensitivity_level`: How sensitive the data in a table is, at most. @@ -68,7 +68,7 @@ class ListTableDataProfilesRequest extends \Google\Protobuf\Internal\Message * sequence of restrictions implicitly uses `AND`. * * A restriction has the form of `{field} {operator} {value}`. * * Supported fields/values: - * - `project_id` - The GCP project ID. + * - `project_id` - The Google Cloud project ID. * - `dataset_id` - The BigQuery dataset ID. * - `table_id` - The ID of the BigQuery table. * - `sensitivity_level` - HIGH|MODERATE|LOW @@ -128,7 +128,7 @@ public static function build(string $parent): self * * `table_id` * * `sensitivity_level desc` * Supported fields are: - * - `project_id`: The GCP project ID. + * - `project_id`: The Google Cloud project ID. * - `dataset_id`: The ID of a BigQuery dataset. * - `table_id`: The ID of a BigQuery table. * - `sensitivity_level`: How sensitive the data in a table is, at most. @@ -146,7 +146,7 @@ public static function build(string $parent): self * sequence of restrictions implicitly uses `AND`. * * A restriction has the form of `{field} {operator} {value}`. * * Supported fields/values: - * - `project_id` - The GCP project ID. + * - `project_id` - The Google Cloud project ID. * - `dataset_id` - The BigQuery dataset ID. * - `table_id` - The ID of the BigQuery table. * - `sensitivity_level` - HIGH|MODERATE|LOW @@ -261,7 +261,7 @@ public function setPageSize($var) * * `table_id` * * `sensitivity_level desc` * Supported fields are: - * - `project_id`: The GCP project ID. + * - `project_id`: The Google Cloud project ID. * - `dataset_id`: The ID of a BigQuery dataset. * - `table_id`: The ID of a BigQuery table. * - `sensitivity_level`: How sensitive the data in a table is, at most. @@ -290,7 +290,7 @@ public function getOrderBy() * * `table_id` * * `sensitivity_level desc` * Supported fields are: - * - `project_id`: The GCP project ID. + * - `project_id`: The Google Cloud project ID. * - `dataset_id`: The ID of a BigQuery dataset. * - `table_id`: The ID of a BigQuery table. * - `sensitivity_level`: How sensitive the data in a table is, at most. @@ -321,7 +321,7 @@ public function setOrderBy($var) * sequence of restrictions implicitly uses `AND`. * * A restriction has the form of `{field} {operator} {value}`. * * Supported fields/values: - * - `project_id` - The GCP project ID. + * - `project_id` - The Google Cloud project ID. * - `dataset_id` - The BigQuery dataset ID. * - `table_id` - The ID of the BigQuery table. * - `sensitivity_level` - HIGH|MODERATE|LOW @@ -352,7 +352,7 @@ public function getFilter() * sequence of restrictions implicitly uses `AND`. * * A restriction has the form of `{field} {operator} {value}`. * * Supported fields/values: - * - `project_id` - The GCP project ID. + * - `project_id` - The Google Cloud project ID. * - `dataset_id` - The BigQuery dataset ID. * - `table_id` - The ID of the BigQuery table. * - `sensitivity_level` - HIGH|MODERATE|LOW diff --git a/Dlp/src/V2/ResourceVisibility.php b/Dlp/src/V2/ResourceVisibility.php index 5094fa621fd7..3fa892868cfd 100644 --- a/Dlp/src/V2/ResourceVisibility.php +++ b/Dlp/src/V2/ResourceVisibility.php @@ -26,6 +26,14 @@ class ResourceVisibility * Generated from protobuf enum RESOURCE_VISIBILITY_PUBLIC = 10; */ const RESOURCE_VISIBILITY_PUBLIC = 10; + /** + * May contain public items. + * For example, if a GCS bucket has uniform bucket level access disabled, some + * objects inside it may be public. + * + * Generated from protobuf enum RESOURCE_VISIBILITY_INCONCLUSIVE = 15; + */ + const RESOURCE_VISIBILITY_INCONCLUSIVE = 15; /** * Visible only to specific users. * @@ -36,6 +44,7 @@ class ResourceVisibility private static $valueToName = [ self::RESOURCE_VISIBILITY_UNSPECIFIED => 'RESOURCE_VISIBILITY_UNSPECIFIED', self::RESOURCE_VISIBILITY_PUBLIC => 'RESOURCE_VISIBILITY_PUBLIC', + self::RESOURCE_VISIBILITY_INCONCLUSIVE => 'RESOURCE_VISIBILITY_INCONCLUSIVE', self::RESOURCE_VISIBILITY_RESTRICTED => 'RESOURCE_VISIBILITY_RESTRICTED', ]; diff --git a/Dlp/src/V2/SearchConnectionsRequest.php b/Dlp/src/V2/SearchConnectionsRequest.php new file mode 100644 index 000000000000..7e060c5c120d --- /dev/null +++ b/Dlp/src/V2/SearchConnectionsRequest.php @@ -0,0 +1,196 @@ +google.privacy.dlp.v2.SearchConnectionsRequest + */ +class SearchConnectionsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Parent name, typically an organization, without location. + * For example: `organizations/12345678`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Optional. Number of results per page, max 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + /** + * Optional. Page token from a previous page to return the next set of + * results. If set, all other request fields must match the original request. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + /** + * Optional. * Supported fields/values + * - `state` - MISSING|AVAILABLE|ERROR + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $filter = ''; + + /** + * @param string $parent Required. Parent name, typically an organization, without location. + * For example: `organizations/12345678`. Please see + * {@see DlpServiceClient::locationName()} for help formatting this field. + * + * @return \Google\Cloud\Dlp\V2\SearchConnectionsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. Parent name, typically an organization, without location. + * For example: `organizations/12345678`. + * @type int $page_size + * Optional. Number of results per page, max 1000. + * @type string $page_token + * Optional. Page token from a previous page to return the next set of + * results. If set, all other request fields must match the original request. + * @type string $filter + * Optional. * Supported fields/values + * - `state` - MISSING|AVAILABLE|ERROR + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Required. Parent name, typically an organization, without location. + * For example: `organizations/12345678`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. Parent name, typically an organization, without location. + * For example: `organizations/12345678`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. Number of results per page, max 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. Number of results per page, max 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Optional. Page token from a previous page to return the next set of + * results. If set, all other request fields must match the original request. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. Page token from a previous page to return the next set of + * results. If set, all other request fields must match the original request. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * Optional. * Supported fields/values + * - `state` - MISSING|AVAILABLE|ERROR + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Optional. * Supported fields/values + * - `state` - MISSING|AVAILABLE|ERROR + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/SearchConnectionsResponse.php b/Dlp/src/V2/SearchConnectionsResponse.php new file mode 100644 index 000000000000..18736b747d98 --- /dev/null +++ b/Dlp/src/V2/SearchConnectionsResponse.php @@ -0,0 +1,113 @@ +google.privacy.dlp.v2.SearchConnectionsResponse + */ +class SearchConnectionsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * List of connections that match the search query. Note that only a subset + * of the fields will be populated, and only "name" is guaranteed to be set. + * For full details of a Connection, call GetConnection with the name. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.Connection connections = 1; + */ + private $connections; + /** + * Token to retrieve the next page of results. An empty value means there are + * no more results. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Dlp\V2\Connection>|\Google\Protobuf\Internal\RepeatedField $connections + * List of connections that match the search query. Note that only a subset + * of the fields will be populated, and only "name" is guaranteed to be set. + * For full details of a Connection, call GetConnection with the name. + * @type string $next_page_token + * Token to retrieve the next page of results. An empty value means there are + * no more results. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * List of connections that match the search query. Note that only a subset + * of the fields will be populated, and only "name" is guaranteed to be set. + * For full details of a Connection, call GetConnection with the name. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.Connection connections = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getConnections() + { + return $this->connections; + } + + /** + * List of connections that match the search query. Note that only a subset + * of the fields will be populated, and only "name" is guaranteed to be set. + * For full details of a Connection, call GetConnection with the name. + * + * Generated from protobuf field repeated .google.privacy.dlp.v2.Connection connections = 1; + * @param array<\Google\Cloud\Dlp\V2\Connection>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setConnections($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\Connection::class); + $this->connections = $arr; + + return $this; + } + + /** + * Token to retrieve the next page of results. An empty value means there are + * no more results. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * Token to retrieve the next page of results. An empty value means there are + * no more results. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/SecretManagerCredential.php b/Dlp/src/V2/SecretManagerCredential.php new file mode 100644 index 000000000000..680f67db3e63 --- /dev/null +++ b/Dlp/src/V2/SecretManagerCredential.php @@ -0,0 +1,108 @@ +google.privacy.dlp.v2.SecretManagerCredential + */ +class SecretManagerCredential extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The username. + * + * Generated from protobuf field string username = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $username = ''; + /** + * Required. The name of the Secret Manager resource that stores the password, + * in the form `projects/project-id/secrets/secret-name/versions/version`. + * + * Generated from protobuf field string password_secret_version_name = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $password_secret_version_name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $username + * Required. The username. + * @type string $password_secret_version_name + * Required. The name of the Secret Manager resource that stores the password, + * in the form `projects/project-id/secrets/secret-name/versions/version`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Required. The username. + * + * Generated from protobuf field string username = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * Required. The username. + * + * Generated from protobuf field string username = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setUsername($var) + { + GPBUtil::checkString($var, True); + $this->username = $var; + + return $this; + } + + /** + * Required. The name of the Secret Manager resource that stores the password, + * in the form `projects/project-id/secrets/secret-name/versions/version`. + * + * Generated from protobuf field string password_secret_version_name = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getPasswordSecretVersionName() + { + return $this->password_secret_version_name; + } + + /** + * Required. The name of the Secret Manager resource that stores the password, + * in the form `projects/project-id/secrets/secret-name/versions/version`. + * + * Generated from protobuf field string password_secret_version_name = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setPasswordSecretVersionName($var) + { + GPBUtil::checkString($var, True); + $this->password_secret_version_name = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/StorageConfig/TimespanConfig.php b/Dlp/src/V2/StorageConfig/TimespanConfig.php index 5732359228ac..26986cae0ae9 100644 --- a/Dlp/src/V2/StorageConfig/TimespanConfig.php +++ b/Dlp/src/V2/StorageConfig/TimespanConfig.php @@ -69,6 +69,14 @@ class TimespanConfig extends \Google\Protobuf\Internal\Message * since the last time the JobTrigger executed. This will be based on the * time of the execution of the last run of the JobTrigger or the timespan * end_time used in the last run of the JobTrigger. + * **For BigQuery** + * Inspect jobs triggered by automatic population will scan data that is at + * least three hours old when the job starts. This is because streaming + * buffer rows are not read during inspection and reading up to the current + * timestamp will result in skipped rows. + * See the [known + * issue](https://cloud.google.com/sensitive-data-protection/docs/known-issues#recently-streamed-data) + * related to this operation. * * Generated from protobuf field bool enable_auto_population_of_timespan_config = 4; */ @@ -121,6 +129,14 @@ class TimespanConfig extends \Google\Protobuf\Internal\Message * since the last time the JobTrigger executed. This will be based on the * time of the execution of the last run of the JobTrigger or the timespan * end_time used in the last run of the JobTrigger. + * **For BigQuery** + * Inspect jobs triggered by automatic population will scan data that is at + * least three hours old when the job starts. This is because streaming + * buffer rows are not read during inspection and reading up to the current + * timestamp will result in skipped rows. + * See the [known + * issue](https://cloud.google.com/sensitive-data-protection/docs/known-issues#recently-streamed-data) + * related to this operation. * } */ public function __construct($data = NULL) { @@ -300,6 +316,14 @@ public function setTimestampField($var) * since the last time the JobTrigger executed. This will be based on the * time of the execution of the last run of the JobTrigger or the timespan * end_time used in the last run of the JobTrigger. + * **For BigQuery** + * Inspect jobs triggered by automatic population will scan data that is at + * least three hours old when the job starts. This is because streaming + * buffer rows are not read during inspection and reading up to the current + * timestamp will result in skipped rows. + * See the [known + * issue](https://cloud.google.com/sensitive-data-protection/docs/known-issues#recently-streamed-data) + * related to this operation. * * Generated from protobuf field bool enable_auto_population_of_timespan_config = 4; * @return bool @@ -315,6 +339,14 @@ public function getEnableAutoPopulationOfTimespanConfig() * since the last time the JobTrigger executed. This will be based on the * time of the execution of the last run of the JobTrigger or the timespan * end_time used in the last run of the JobTrigger. + * **For BigQuery** + * Inspect jobs triggered by automatic population will scan data that is at + * least three hours old when the job starts. This is because streaming + * buffer rows are not read during inspection and reading up to the current + * timestamp will result in skipped rows. + * See the [known + * issue](https://cloud.google.com/sensitive-data-protection/docs/known-issues#recently-streamed-data) + * related to this operation. * * Generated from protobuf field bool enable_auto_population_of_timespan_config = 4; * @param bool $var diff --git a/Dlp/src/V2/UpdateConnectionRequest.php b/Dlp/src/V2/UpdateConnectionRequest.php new file mode 100644 index 000000000000..f78d2bae87af --- /dev/null +++ b/Dlp/src/V2/UpdateConnectionRequest.php @@ -0,0 +1,174 @@ +google.privacy.dlp.v2.UpdateConnectionRequest + */ +class UpdateConnectionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + /** + * Required. The connection with new values for the relevant fields. + * + * Generated from protobuf field .google.privacy.dlp.v2.Connection connection = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $connection = null; + /** + * Optional. Mask to control which fields get updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $update_mask = null; + + /** + * @param string $name Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. Please see + * {@see DlpServiceClient::connectionName()} for help formatting this field. + * + * @return \Google\Cloud\Dlp\V2\UpdateConnectionRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * @type \Google\Cloud\Dlp\V2\Connection $connection + * Required. The connection with new values for the relevant fields. + * @type \Google\Protobuf\FieldMask $update_mask + * Optional. Mask to control which fields get updated. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Privacy\Dlp\V2\Dlp::initOnce(); + parent::__construct($data); + } + + /** + * Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. Resource name in the format: + * `projects/{project}/locations/{location}/connections/{connection}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The connection with new values for the relevant fields. + * + * Generated from protobuf field .google.privacy.dlp.v2.Connection connection = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Dlp\V2\Connection|null + */ + public function getConnection() + { + return $this->connection; + } + + public function hasConnection() + { + return isset($this->connection); + } + + public function clearConnection() + { + unset($this->connection); + } + + /** + * Required. The connection with new values for the relevant fields. + * + * Generated from protobuf field .google.privacy.dlp.v2.Connection connection = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Dlp\V2\Connection $var + * @return $this + */ + public function setConnection($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Connection::class); + $this->connection = $var; + + return $this; + } + + /** + * Optional. Mask to control which fields get updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Optional. Mask to control which fields get updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/Dlp/src/V2/gapic_metadata.json b/Dlp/src/V2/gapic_metadata.json index 7635b41e01ba..57d81805f598 100644 --- a/Dlp/src/V2/gapic_metadata.json +++ b/Dlp/src/V2/gapic_metadata.json @@ -20,6 +20,11 @@ "cancelDlpJob" ] }, + "CreateConnection": { + "methods": [ + "createConnection" + ] + }, "CreateDeidentifyTemplate": { "methods": [ "createDeidentifyTemplate" @@ -55,6 +60,11 @@ "deidentifyContent" ] }, + "DeleteConnection": { + "methods": [ + "deleteConnection" + ] + }, "DeleteDeidentifyTemplate": { "methods": [ "deleteDeidentifyTemplate" @@ -85,6 +95,11 @@ "deleteStoredInfoType" ] }, + "DeleteTableDataProfile": { + "methods": [ + "deleteTableDataProfile" + ] + }, "FinishDlpJob": { "methods": [ "finishDlpJob" @@ -95,6 +110,11 @@ "getColumnDataProfile" ] }, + "GetConnection": { + "methods": [ + "getConnection" + ] + }, "GetDeidentifyTemplate": { "methods": [ "getDeidentifyTemplate" @@ -155,6 +175,11 @@ "listColumnDataProfiles" ] }, + "ListConnections": { + "methods": [ + "listConnections" + ] + }, "ListDeidentifyTemplates": { "methods": [ "listDeidentifyTemplates" @@ -210,6 +235,16 @@ "reidentifyContent" ] }, + "SearchConnections": { + "methods": [ + "searchConnections" + ] + }, + "UpdateConnection": { + "methods": [ + "updateConnection" + ] + }, "UpdateDeidentifyTemplate": { "methods": [ "updateDeidentifyTemplate" diff --git a/Dlp/src/V2/resources/dlp_service_client_config.json b/Dlp/src/V2/resources/dlp_service_client_config.json index 983ae181e6b0..78363c7bd2aa 100644 --- a/Dlp/src/V2/resources/dlp_service_client_config.json +++ b/Dlp/src/V2/resources/dlp_service_client_config.json @@ -49,6 +49,11 @@ "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" }, + "CreateConnection": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "CreateDeidentifyTemplate": { "timeout_millis": 300000, "retry_codes_name": "no_retry_1_codes", @@ -84,6 +89,11 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "DeleteConnection": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "DeleteDeidentifyTemplate": { "timeout_millis": 300000, "retry_codes_name": "retry_policy_1_codes", @@ -114,6 +124,11 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "DeleteTableDataProfile": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "FinishDlpJob": { "timeout_millis": 300000, "retry_codes_name": "no_retry_1_codes", @@ -124,6 +139,11 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "GetConnection": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "GetDeidentifyTemplate": { "timeout_millis": 300000, "retry_codes_name": "retry_policy_1_codes", @@ -184,6 +204,11 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "ListConnections": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "ListDeidentifyTemplates": { "timeout_millis": 300000, "retry_codes_name": "retry_policy_1_codes", @@ -239,6 +264,16 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "SearchConnections": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "UpdateConnection": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "UpdateDeidentifyTemplate": { "timeout_millis": 300000, "retry_codes_name": "no_retry_1_codes", diff --git a/Dlp/src/V2/resources/dlp_service_descriptor_config.php b/Dlp/src/V2/resources/dlp_service_descriptor_config.php index 515aea5bc9a7..0ce9d36ad4b5 100644 --- a/Dlp/src/V2/resources/dlp_service_descriptor_config.php +++ b/Dlp/src/V2/resources/dlp_service_descriptor_config.php @@ -47,6 +47,18 @@ ], ], ], + 'CreateConnection' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dlp\V2\Connection', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'CreateDeidentifyTemplate' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\Dlp\V2\DeidentifyTemplate', @@ -131,6 +143,18 @@ ], ], ], + 'DeleteConnection' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'DeleteDeidentifyTemplate' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Protobuf\GPBEmpty', @@ -203,6 +227,18 @@ ], ], ], + 'DeleteTableDataProfile' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'FinishDlpJob' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Protobuf\GPBEmpty', @@ -227,6 +263,18 @@ ], ], ], + 'GetConnection' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dlp\V2\Connection', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'GetDeidentifyTemplate' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\Dlp\V2\DeidentifyTemplate', @@ -379,6 +427,26 @@ ], ], ], + 'ListConnections' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getConnections', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dlp\V2\ListConnectionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'ListDeidentifyTemplates' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -575,6 +643,38 @@ ], ], ], + 'SearchConnections' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getConnections', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dlp\V2\SearchConnectionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateConnection' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dlp\V2\Connection', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'UpdateDeidentifyTemplate' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\Dlp\V2\DeidentifyTemplate', @@ -637,6 +737,7 @@ ], 'templateMap' => [ 'columnDataProfile' => 'organizations/{organization}/locations/{location}/columnDataProfiles/{column_data_profile}', + 'connection' => 'projects/{project}/locations/{location}/connections/{connection}', 'deidentifyTemplate' => 'organizations/{organization}/deidentifyTemplates/{deidentify_template}', 'discoveryConfig' => 'projects/{project}/locations/{location}/discoveryConfigs/{discovery_config}', 'dlpJob' => 'projects/{project}/dlpJobs/{dlp_job}', diff --git a/Dlp/src/V2/resources/dlp_service_rest_client_config.php b/Dlp/src/V2/resources/dlp_service_rest_client_config.php index fe53b1b2fad3..e2def05b8c3b 100644 --- a/Dlp/src/V2/resources/dlp_service_rest_client_config.php +++ b/Dlp/src/V2/resources/dlp_service_rest_client_config.php @@ -61,6 +61,18 @@ ], ], ], + 'CreateConnection' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*}/connections', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'CreateDeidentifyTemplate' => [ 'method' => 'post', 'uriTemplate' => '/v2/{parent=organizations/*}/deidentifyTemplates', @@ -229,6 +241,17 @@ ], ], ], + 'DeleteConnection' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/connections/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'DeleteDeidentifyTemplate' => [ 'method' => 'delete', 'uriTemplate' => '/v2/{name=organizations/*/deidentifyTemplates/*}', @@ -359,6 +382,23 @@ ], ], ], + 'DeleteTableDataProfile' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=organizations/*/locations/*/tableDataProfiles/*}', + 'additionalBindings' => [ + [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/tableDataProfiles/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'FinishDlpJob' => [ 'method' => 'post', 'uriTemplate' => '/v2/{name=projects/*/locations/*/dlpJobs/*}:finish', @@ -388,6 +428,17 @@ ], ], ], + 'GetConnection' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/connections/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'GetDeidentifyTemplate' => [ 'method' => 'get', 'uriTemplate' => '/v2/{name=organizations/*/deidentifyTemplates/*}', @@ -612,6 +663,17 @@ ], ], ], + 'ListConnections' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*}/connections', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'ListDeidentifyTemplates' => [ 'method' => 'get', 'uriTemplate' => '/v2/{parent=organizations/*}/deidentifyTemplates', @@ -835,6 +897,35 @@ ], ], ], + 'SearchConnections' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*}/connections:search', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=organizations/*/locations/*}/connections:search', + ], + ], + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateConnection' => [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/connections/*}', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'UpdateDeidentifyTemplate' => [ 'method' => 'patch', 'uriTemplate' => '/v2/{name=organizations/*/deidentifyTemplates/*}', diff --git a/Dlp/tests/Unit/V2/Client/DlpServiceClientTest.php b/Dlp/tests/Unit/V2/Client/DlpServiceClientTest.php index 6707ab648596..165f09aa9468 100644 --- a/Dlp/tests/Unit/V2/Client/DlpServiceClientTest.php +++ b/Dlp/tests/Unit/V2/Client/DlpServiceClientTest.php @@ -30,6 +30,9 @@ use Google\Cloud\Dlp\V2\CancelDlpJobRequest; use Google\Cloud\Dlp\V2\Client\DlpServiceClient; use Google\Cloud\Dlp\V2\ColumnDataProfile; +use Google\Cloud\Dlp\V2\Connection; +use Google\Cloud\Dlp\V2\ConnectionState; +use Google\Cloud\Dlp\V2\CreateConnectionRequest; use Google\Cloud\Dlp\V2\CreateDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\CreateDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\CreateDlpJobRequest; @@ -39,17 +42,20 @@ use Google\Cloud\Dlp\V2\DeidentifyContentRequest; use Google\Cloud\Dlp\V2\DeidentifyContentResponse; use Google\Cloud\Dlp\V2\DeidentifyTemplate; +use Google\Cloud\Dlp\V2\DeleteConnectionRequest; use Google\Cloud\Dlp\V2\DeleteDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\DeleteDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\DeleteDlpJobRequest; use Google\Cloud\Dlp\V2\DeleteInspectTemplateRequest; use Google\Cloud\Dlp\V2\DeleteJobTriggerRequest; use Google\Cloud\Dlp\V2\DeleteStoredInfoTypeRequest; +use Google\Cloud\Dlp\V2\DeleteTableDataProfileRequest; use Google\Cloud\Dlp\V2\DiscoveryConfig; use Google\Cloud\Dlp\V2\DiscoveryConfig\Status; use Google\Cloud\Dlp\V2\DlpJob; use Google\Cloud\Dlp\V2\FinishDlpJobRequest; use Google\Cloud\Dlp\V2\GetColumnDataProfileRequest; +use Google\Cloud\Dlp\V2\GetConnectionRequest; use Google\Cloud\Dlp\V2\GetDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\GetDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\GetDlpJobRequest; @@ -67,6 +73,8 @@ use Google\Cloud\Dlp\V2\JobTrigger; use Google\Cloud\Dlp\V2\ListColumnDataProfilesRequest; use Google\Cloud\Dlp\V2\ListColumnDataProfilesResponse; +use Google\Cloud\Dlp\V2\ListConnectionsRequest; +use Google\Cloud\Dlp\V2\ListConnectionsResponse; use Google\Cloud\Dlp\V2\ListDeidentifyTemplatesRequest; use Google\Cloud\Dlp\V2\ListDeidentifyTemplatesResponse; use Google\Cloud\Dlp\V2\ListDiscoveryConfigsRequest; @@ -90,9 +98,12 @@ use Google\Cloud\Dlp\V2\RedactImageResponse; use Google\Cloud\Dlp\V2\ReidentifyContentRequest; use Google\Cloud\Dlp\V2\ReidentifyContentResponse; +use Google\Cloud\Dlp\V2\SearchConnectionsRequest; +use Google\Cloud\Dlp\V2\SearchConnectionsResponse; use Google\Cloud\Dlp\V2\StoredInfoType; use Google\Cloud\Dlp\V2\StoredInfoTypeConfig; use Google\Cloud\Dlp\V2\TableDataProfile; +use Google\Cloud\Dlp\V2\UpdateConnectionRequest; use Google\Cloud\Dlp\V2\UpdateDeidentifyTemplateRequest; use Google\Cloud\Dlp\V2\UpdateDiscoveryConfigRequest; use Google\Cloud\Dlp\V2\UpdateInspectTemplateRequest; @@ -257,6 +268,80 @@ public function cancelDlpJobExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function createConnectionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $expectedResponse = new Connection(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $connection = new Connection(); + $connectionState = ConnectionState::CONNECTION_STATE_UNSPECIFIED; + $connection->setState($connectionState); + $request = (new CreateConnectionRequest()) + ->setParent($formattedParent) + ->setConnection($connection); + $response = $gapicClient->createConnection($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/CreateConnection', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getConnection(); + $this->assertProtobufEquals($connection, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createConnectionExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $connection = new Connection(); + $connectionState = ConnectionState::CONNECTION_STATE_UNSPECIFIED; + $connection->setState($connectionState); + $request = (new CreateConnectionRequest()) + ->setParent($formattedParent) + ->setConnection($connection); + try { + $gapicClient->createConnection($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function createDeidentifyTemplateTest() { @@ -749,6 +834,67 @@ public function deidentifyContentExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function deleteConnectionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $request = (new DeleteConnectionRequest()) + ->setName($formattedName); + $gapicClient->deleteConnection($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/DeleteConnection', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteConnectionExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $request = (new DeleteConnectionRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteConnection($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function deleteDeidentifyTemplateTest() { @@ -1115,6 +1261,67 @@ public function deleteStoredInfoTypeExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function deleteTableDataProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->tableDataProfileName('[ORGANIZATION]', '[LOCATION]', '[TABLE_DATA_PROFILE]'); + $request = (new DeleteTableDataProfileRequest()) + ->setName($formattedName); + $gapicClient->deleteTableDataProfile($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/DeleteTableDataProfile', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteTableDataProfileExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->tableDataProfileName('[ORGANIZATION]', '[LOCATION]', '[TABLE_DATA_PROFILE]'); + $request = (new DeleteTableDataProfileRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteTableDataProfile($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function finishDlpJobTest() { @@ -1256,6 +1463,70 @@ public function getColumnDataProfileExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function getConnectionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new Connection(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $request = (new GetConnectionRequest()) + ->setName($formattedName); + $response = $gapicClient->getConnection($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/GetConnection', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getConnectionExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $request = (new GetConnectionRequest()) + ->setName($formattedName); + try { + $gapicClient->getConnection($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function getDeidentifyTemplateTest() { @@ -2056,6 +2327,78 @@ public function listColumnDataProfilesExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listConnectionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $connectionsElement = new Connection(); + $connections = [ + $connectionsElement, + ]; + $expectedResponse = new ListConnectionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setConnections($connections); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListConnectionsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listConnections($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getConnections()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/ListConnections', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listConnectionsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListConnectionsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listConnections($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function listDeidentifyTemplatesTest() { @@ -2806,6 +3149,152 @@ public function reidentifyContentExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function searchConnectionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $connectionsElement = new Connection(); + $connections = [ + $connectionsElement, + ]; + $expectedResponse = new SearchConnectionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setConnections($connections); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new SearchConnectionsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->searchConnections($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getConnections()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/SearchConnections', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function searchConnectionsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new SearchConnectionsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->searchConnections($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateConnectionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new Connection(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $connection = new Connection(); + $connectionState = ConnectionState::CONNECTION_STATE_UNSPECIFIED; + $connection->setState($connectionState); + $request = (new UpdateConnectionRequest()) + ->setName($formattedName) + ->setConnection($connection); + $response = $gapicClient->updateConnection($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/UpdateConnection', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualRequestObject->getConnection(); + $this->assertProtobufEquals($connection, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateConnectionExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $connection = new Connection(); + $connectionState = ConnectionState::CONNECTION_STATE_UNSPECIFIED; + $connection->setState($connectionState); + $request = (new UpdateConnectionRequest()) + ->setName($formattedName) + ->setConnection($connection); + try { + $gapicClient->updateConnection($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function updateDeidentifyTemplateTest() { diff --git a/Dlp/tests/Unit/V2/DlpServiceClientTest.php b/Dlp/tests/Unit/V2/DlpServiceClientTest.php index b2979244f6ca..aea29b7e536b 100644 --- a/Dlp/tests/Unit/V2/DlpServiceClientTest.php +++ b/Dlp/tests/Unit/V2/DlpServiceClientTest.php @@ -27,6 +27,8 @@ use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; use Google\Cloud\Dlp\V2\ColumnDataProfile; +use Google\Cloud\Dlp\V2\Connection; +use Google\Cloud\Dlp\V2\ConnectionState; use Google\Cloud\Dlp\V2\DeidentifyContentResponse; use Google\Cloud\Dlp\V2\DeidentifyTemplate; use Google\Cloud\Dlp\V2\DiscoveryConfig; @@ -38,6 +40,7 @@ use Google\Cloud\Dlp\V2\InspectTemplate; use Google\Cloud\Dlp\V2\JobTrigger; use Google\Cloud\Dlp\V2\ListColumnDataProfilesResponse; +use Google\Cloud\Dlp\V2\ListConnectionsResponse; use Google\Cloud\Dlp\V2\ListDeidentifyTemplatesResponse; use Google\Cloud\Dlp\V2\ListDiscoveryConfigsResponse; use Google\Cloud\Dlp\V2\ListDlpJobsResponse; @@ -50,6 +53,7 @@ use Google\Cloud\Dlp\V2\ProjectDataProfile; use Google\Cloud\Dlp\V2\RedactImageResponse; use Google\Cloud\Dlp\V2\ReidentifyContentResponse; +use Google\Cloud\Dlp\V2\SearchConnectionsResponse; use Google\Cloud\Dlp\V2\StoredInfoType; use Google\Cloud\Dlp\V2\StoredInfoTypeConfig; use Google\Cloud\Dlp\V2\TableDataProfile; @@ -204,6 +208,74 @@ public function cancelDlpJobExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function createConnectionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $expectedResponse = new Connection(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $connection = new Connection(); + $connectionState = ConnectionState::CONNECTION_STATE_UNSPECIFIED; + $connection->setState($connectionState); + $response = $gapicClient->createConnection($formattedParent, $connection); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/CreateConnection', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getConnection(); + $this->assertProtobufEquals($connection, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createConnectionExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $connection = new Connection(); + $connectionState = ConnectionState::CONNECTION_STATE_UNSPECIFIED; + $connection->setState($connectionState); + try { + $gapicClient->createConnection($formattedParent, $connection); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function createDeidentifyTemplateTest() { @@ -660,6 +732,63 @@ public function deidentifyContentExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function deleteConnectionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $gapicClient->deleteConnection($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/DeleteConnection', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteConnectionExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + try { + $gapicClient->deleteConnection($formattedName); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function deleteDeidentifyTemplateTest() { @@ -1002,6 +1131,63 @@ public function deleteStoredInfoTypeExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function deleteTableDataProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->tableDataProfileName('[ORGANIZATION]', '[LOCATION]', '[TABLE_DATA_PROFILE]'); + $gapicClient->deleteTableDataProfile($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/DeleteTableDataProfile', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteTableDataProfileExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->tableDataProfileName('[ORGANIZATION]', '[LOCATION]', '[TABLE_DATA_PROFILE]'); + try { + $gapicClient->deleteTableDataProfile($formattedName); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function finishDlpJobTest() { @@ -1135,6 +1321,66 @@ public function getColumnDataProfileExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function getConnectionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new Connection(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $response = $gapicClient->getConnection($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/GetConnection', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getConnectionExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + try { + $gapicClient->getConnection($formattedName); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function getDeidentifyTemplateTest() { @@ -1889,6 +2135,74 @@ public function listColumnDataProfilesExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listConnectionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $connectionsElement = new Connection(); + $connections = [ + $connectionsElement, + ]; + $expectedResponse = new ListConnectionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setConnections($connections); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $response = $gapicClient->listConnections($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getConnections()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/ListConnections', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listConnectionsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + try { + $gapicClient->listConnections($formattedParent); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function listDeidentifyTemplatesTest() { @@ -2599,6 +2913,142 @@ public function reidentifyContentExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function searchConnectionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $connectionsElement = new Connection(); + $connections = [ + $connectionsElement, + ]; + $expectedResponse = new SearchConnectionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setConnections($connections); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $response = $gapicClient->searchConnections($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getConnections()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/SearchConnections', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function searchConnectionsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + try { + $gapicClient->searchConnections($formattedParent); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateConnectionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $expectedResponse = new Connection(); + $expectedResponse->setName($name2); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $connection = new Connection(); + $connectionState = ConnectionState::CONNECTION_STATE_UNSPECIFIED; + $connection->setState($connectionState); + $response = $gapicClient->updateConnection($formattedName, $connection); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.privacy.dlp.v2.DlpService/UpdateConnection', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualRequestObject->getConnection(); + $this->assertProtobufEquals($connection, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateConnectionExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $connection = new Connection(); + $connectionState = ConnectionState::CONNECTION_STATE_UNSPECIFIED; + $connection->setState($connectionState); + try { + $gapicClient->updateConnection($formattedName, $connection); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function updateDeidentifyTemplateTest() {