Skip to content

Commit

Permalink
feat: Add UnenrollDataSources API which gives users a programmatic wa…
Browse files Browse the repository at this point in the history
…y to unenroll data sources (#7054)

PiperOrigin-RevId: 606248188
Source-Link: googleapis/googleapis@fa4f91a
Source-Link: googleapis/googleapis-gen@05afb31
Copy-Tag: eyJwIjoiQmlnUXVlcnlEYXRhVHJhbnNmZXIvLk93bEJvdC55YW1sIiwiaCI6IjA1YWZiMzEzMzJmYjg5NWRjMGZkMWI4MjJiYTUwZDQ5ZWViZDM0MDYifQ==
  • Loading branch information
gcf-owl-bot[bot] committed Feb 14, 2024
1 parent f0b9b05 commit bb09037
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 0 deletions.
Binary file modified BigQueryDataTransfer/metadata/V1/Datatransfer.php
Binary file not shown.
@@ -0,0 +1,58 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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

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

// [START bigquerydatatransfer_v1_generated_DataTransferService_UnenrollDataSources_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\BigQuery\DataTransfer\V1\Client\DataTransferServiceClient;
use Google\Cloud\BigQuery\DataTransfer\V1\UnenrollDataSourcesRequest;

/**
* Unenroll data sources in a user project. This allows users to remove
* transfer configurations for these data sources. They will no longer appear
* in the ListDataSources RPC and will also no longer appear in the [BigQuery
* UI](https://console.cloud.google.com/bigquery).
*
* 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 unenroll_data_sources_sample(): void
{
// Create a client.
$dataTransferServiceClient = new DataTransferServiceClient();

// Prepare the request message.
$request = new UnenrollDataSourcesRequest();

// Call the API and handle any network failures.
try {
$dataTransferServiceClient->unenrollDataSources($request);
printf('Call completed successfully.' . PHP_EOL);
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
// [END bigquerydatatransfer_v1_generated_DataTransferService_UnenrollDataSources_sync]
30 changes: 30 additions & 0 deletions BigQueryDataTransfer/src/V1/Client/DataTransferServiceClient.php
Expand Up @@ -53,6 +53,7 @@
use Google\Cloud\BigQuery\DataTransfer\V1\StartManualTransferRunsResponse;
use Google\Cloud\BigQuery\DataTransfer\V1\TransferConfig;
use Google\Cloud\BigQuery\DataTransfer\V1\TransferRun;
use Google\Cloud\BigQuery\DataTransfer\V1\UnenrollDataSourcesRequest;
use Google\Cloud\BigQuery\DataTransfer\V1\UpdateTransferConfigRequest;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\ListLocationsRequest;
Expand Down Expand Up @@ -84,6 +85,7 @@
* @method PromiseInterface listTransferRunsAsync(ListTransferRunsRequest $request, array $optionalArgs = [])
* @method PromiseInterface scheduleTransferRunsAsync(ScheduleTransferRunsRequest $request, array $optionalArgs = [])
* @method PromiseInterface startManualTransferRunsAsync(StartManualTransferRunsRequest $request, array $optionalArgs = [])
* @method PromiseInterface unenrollDataSourcesAsync(UnenrollDataSourcesRequest $request, array $optionalArgs = [])
* @method PromiseInterface updateTransferConfigAsync(UpdateTransferConfigRequest $request, array $optionalArgs = [])
* @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = [])
* @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = [])
Expand Down Expand Up @@ -823,6 +825,34 @@ public function startManualTransferRuns(StartManualTransferRunsRequest $request,
return $this->startApiCall('StartManualTransferRuns', $request, $callOptions)->wait();
}

/**
* Unenroll data sources in a user project. This allows users to remove
* transfer configurations for these data sources. They will no longer appear
* in the ListDataSources RPC and will also no longer appear in the [BigQuery
* UI](https://console.cloud.google.com/bigquery).
*
* The async variant is
* {@see DataTransferServiceClient::unenrollDataSourcesAsync()} .
*
* @example samples/V1/DataTransferServiceClient/unenroll_data_sources.php
*
* @param UnenrollDataSourcesRequest $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 unenrollDataSources(UnenrollDataSourcesRequest $request, array $callOptions = []): void
{
$this->startApiCall('UnenrollDataSources', $request, $callOptions)->wait();
}

/**
* Updates a data transfer configuration.
* All fields must be set, even if they are not updated.
Expand Down
Expand Up @@ -59,6 +59,7 @@
use Google\Cloud\BigQuery\DataTransfer\V1\StartManualTransferRunsResponse;
use Google\Cloud\BigQuery\DataTransfer\V1\TransferConfig;
use Google\Cloud\BigQuery\DataTransfer\V1\TransferRun;
use Google\Cloud\BigQuery\DataTransfer\V1\UnenrollDataSourcesRequest;
use Google\Cloud\BigQuery\DataTransfer\V1\UpdateTransferConfigRequest;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\ListLocationsRequest;
Expand Down Expand Up @@ -1418,6 +1419,56 @@ public function startManualTransferRuns(array $optionalArgs = [])
return $this->startCall('StartManualTransferRuns', StartManualTransferRunsResponse::class, $optionalArgs, $request)->wait();
}

/**
* Unenroll data sources in a user project. This allows users to remove
* transfer configurations for these data sources. They will no longer appear
* in the ListDataSources RPC and will also no longer appear in the [BigQuery
* UI](https://console.cloud.google.com/bigquery).
*
* Sample code:
* ```
* $dataTransferServiceClient = new DataTransferServiceClient();
* try {
* $dataTransferServiceClient->unenrollDataSources();
* } finally {
* $dataTransferServiceClient->close();
* }
* ```
*
* @param array $optionalArgs {
* Optional.
*
* @type string $name
* The name of the project resource in the form: `projects/{project_id}`
* @type string[] $dataSourceIds
* Data sources that are unenrolled. It is required to provide at least one
* data source id.
* @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 unenrollDataSources(array $optionalArgs = [])
{
$request = new UnenrollDataSourcesRequest();
$requestParamHeaders = [];
if (isset($optionalArgs['name'])) {
$request->setName($optionalArgs['name']);
$requestParamHeaders['name'] = $optionalArgs['name'];
}

if (isset($optionalArgs['dataSourceIds'])) {
$request->setDataSourceIds($optionalArgs['dataSourceIds']);
}

$requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders);
$optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader();
return $this->startCall('UnenrollDataSources', GPBEmpty::class, $optionalArgs, $request)->wait();
}

/**
* Updates a data transfer configuration.
* All fields must be set, even if they are not updated.
Expand Down
106 changes: 106 additions & 0 deletions BigQueryDataTransfer/src/V1/UnenrollDataSourcesRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions BigQueryDataTransfer/src/V1/gapic_metadata.json
Expand Up @@ -80,6 +80,11 @@
"startManualTransferRuns"
]
},
"UnenrollDataSources": {
"methods": [
"unenrollDataSources"
]
},
"UpdateTransferConfig": {
"methods": [
"updateTransferConfig"
Expand Down
Expand Up @@ -109,6 +109,11 @@
"retry_codes_name": "no_retry_codes",
"retry_params_name": "no_retry_params"
},
"UnenrollDataSources": {
"timeout_millis": 60000,
"retry_codes_name": "no_retry_codes",
"retry_params_name": "no_retry_params"
},
"UpdateTransferConfig": {
"timeout_millis": 30000,
"retry_codes_name": "no_retry_1_codes",
Expand Down
Expand Up @@ -203,6 +203,18 @@
],
],
],
'UnenrollDataSources' => [
'callType' => \Google\ApiCore\Call::UNARY_CALL,
'responseType' => 'Google\Protobuf\GPBEmpty',
'headerParams' => [
[
'keyName' => 'name',
'fieldAccessors' => [
'getName',
],
],
],
],
'UpdateTransferConfig' => [
'callType' => \Google\ApiCore\Call::UNARY_CALL,
'responseType' => 'Google\Cloud\BigQuery\DataTransfer\V1\TransferConfig',
Expand Down
Expand Up @@ -251,6 +251,18 @@
],
],
],
'UnenrollDataSources' => [
'method' => 'post',
'uriTemplate' => '/v1/{name=projects/*/locations/*}:unenrollDataSources',
'body' => '*',
'placeholders' => [
'name' => [
'getters' => [
'getName',
],
],
],
],
'UpdateTransferConfig' => [
'method' => 'patch',
'uriTemplate' => '/v1/{transfer_config.name=projects/*/locations/*/transferConfigs/*}',
Expand Down

0 comments on commit bb09037

Please sign in to comment.