-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added Admin Interface (v1) (#6414)
feat: added gRPC endpoint protocol (v1) feat: added BigQuery as a backend metastore (v1) PiperOrigin-RevId: 545570906 Source-Link: googleapis/googleapis@ba4742e Source-Link: googleapis/googleapis-gen@ab122fc Copy-Tag: eyJwIjoiRGF0YXByb2NNZXRhc3RvcmUvLk93bEJvdC55YW1sIiwiaCI6ImFiMTIyZmNkZmMyNjhmNzU3NjM3ZmQ1Yzc0ZDliOWY5NjVkMDJjZjMifQ==
- Loading branch information
1 parent
62734f1
commit 6b794b6
Showing
28 changed files
with
2,528 additions
and
30 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
104 changes: 104 additions & 0 deletions
104
DataprocMetastore/samples/V1/DataprocMetastoreClient/alter_metadata_resource_location.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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 metastore_v1_generated_DataprocMetastore_AlterMetadataResourceLocation_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Cloud\Metastore\V1\AlterMetadataResourceLocationRequest; | ||
use Google\Cloud\Metastore\V1\AlterMetadataResourceLocationResponse; | ||
use Google\Cloud\Metastore\V1\Client\DataprocMetastoreClient; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Alter metadata resource location. The metadata resource can be a database, | ||
* table, or partition. This functionality only updates the parent directory | ||
* for the respective metadata resource and does not transfer any existing | ||
* data to the new location. | ||
* | ||
* @param string $formattedService The relative resource name of the metastore service to mutate | ||
* metadata, in the following format: | ||
* | ||
* `projects/{project_id}/locations/{location_id}/services/{service_id}`. Please see | ||
* {@see DataprocMetastoreClient::serviceName()} for help formatting this field. | ||
* @param string $resourceName The relative metadata resource name in the following format. | ||
* | ||
* `databases/{database_id}` | ||
* or | ||
* `databases/{database_id}/tables/{table_id}` | ||
* or | ||
* `databases/{database_id}/tables/{table_id}/partitions/{partition_id}` | ||
* @param string $locationUri The new location URI for the metadata resource. | ||
*/ | ||
function alter_metadata_resource_location_sample( | ||
string $formattedService, | ||
string $resourceName, | ||
string $locationUri | ||
): void { | ||
// Create a client. | ||
$dataprocMetastoreClient = new DataprocMetastoreClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new AlterMetadataResourceLocationRequest()) | ||
->setService($formattedService) | ||
->setResourceName($resourceName) | ||
->setLocationUri($locationUri); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $dataprocMetastoreClient->alterMetadataResourceLocation($request); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var AlterMetadataResourceLocationResponse $result */ | ||
$result = $response->getResult(); | ||
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); | ||
} else { | ||
/** @var Status $error */ | ||
$error = $response->getError(); | ||
printf('Operation failed with error data: %s' . PHP_EOL, $error->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 | ||
{ | ||
$formattedService = DataprocMetastoreClient::serviceName('[PROJECT]', '[LOCATION]', '[SERVICE]'); | ||
$resourceName = '[RESOURCE_NAME]'; | ||
$locationUri = '[LOCATION_URI]'; | ||
|
||
alter_metadata_resource_location_sample($formattedService, $resourceName, $locationUri); | ||
} | ||
// [END metastore_v1_generated_DataprocMetastore_AlterMetadataResourceLocation_sync] |
99 changes: 99 additions & 0 deletions
99
DataprocMetastore/samples/V1/DataprocMetastoreClient/move_table_to_database.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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 metastore_v1_generated_DataprocMetastore_MoveTableToDatabase_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Cloud\Metastore\V1\Client\DataprocMetastoreClient; | ||
use Google\Cloud\Metastore\V1\MoveTableToDatabaseRequest; | ||
use Google\Cloud\Metastore\V1\MoveTableToDatabaseResponse; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Move a table to another database. | ||
* | ||
* @param string $formattedService The relative resource name of the metastore service to mutate | ||
* metadata, in the following format: | ||
* | ||
* `projects/{project_id}/locations/{location_id}/services/{service_id}`. Please see | ||
* {@see DataprocMetastoreClient::serviceName()} for help formatting this field. | ||
* @param string $tableName The name of the table to be moved. | ||
* @param string $dbName The name of the database where the table resides. | ||
* @param string $destinationDbName The name of the database where the table should be moved. | ||
*/ | ||
function move_table_to_database_sample( | ||
string $formattedService, | ||
string $tableName, | ||
string $dbName, | ||
string $destinationDbName | ||
): void { | ||
// Create a client. | ||
$dataprocMetastoreClient = new DataprocMetastoreClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new MoveTableToDatabaseRequest()) | ||
->setService($formattedService) | ||
->setTableName($tableName) | ||
->setDbName($dbName) | ||
->setDestinationDbName($destinationDbName); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $dataprocMetastoreClient->moveTableToDatabase($request); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var MoveTableToDatabaseResponse $result */ | ||
$result = $response->getResult(); | ||
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); | ||
} else { | ||
/** @var Status $error */ | ||
$error = $response->getError(); | ||
printf('Operation failed with error data: %s' . PHP_EOL, $error->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 | ||
{ | ||
$formattedService = DataprocMetastoreClient::serviceName('[PROJECT]', '[LOCATION]', '[SERVICE]'); | ||
$tableName = '[TABLE_NAME]'; | ||
$dbName = '[DB_NAME]'; | ||
$destinationDbName = '[DESTINATION_DB_NAME]'; | ||
|
||
move_table_to_database_sample($formattedService, $tableName, $dbName, $destinationDbName); | ||
} | ||
// [END metastore_v1_generated_DataprocMetastore_MoveTableToDatabase_sync] |
90 changes: 90 additions & 0 deletions
90
DataprocMetastore/samples/V1/DataprocMetastoreClient/query_metadata.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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 metastore_v1_generated_DataprocMetastore_QueryMetadata_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Cloud\Metastore\V1\Client\DataprocMetastoreClient; | ||
use Google\Cloud\Metastore\V1\QueryMetadataRequest; | ||
use Google\Cloud\Metastore\V1\QueryMetadataResponse; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Query DPMS metadata. | ||
* | ||
* @param string $formattedService The relative resource name of the metastore service to query | ||
* metadata, in the following format: | ||
* | ||
* `projects/{project_id}/locations/{location_id}/services/{service_id}`. Please see | ||
* {@see DataprocMetastoreClient::serviceName()} for help formatting this field. | ||
* @param string $query A read-only SQL query to execute against the metadata database. | ||
* The query cannot change or mutate the data. | ||
*/ | ||
function query_metadata_sample(string $formattedService, string $query): void | ||
{ | ||
// Create a client. | ||
$dataprocMetastoreClient = new DataprocMetastoreClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new QueryMetadataRequest()) | ||
->setService($formattedService) | ||
->setQuery($query); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $dataprocMetastoreClient->queryMetadata($request); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var QueryMetadataResponse $result */ | ||
$result = $response->getResult(); | ||
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); | ||
} else { | ||
/** @var Status $error */ | ||
$error = $response->getError(); | ||
printf('Operation failed with error data: %s' . PHP_EOL, $error->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 | ||
{ | ||
$formattedService = DataprocMetastoreClient::serviceName('[PROJECT]', '[LOCATION]', '[SERVICE]'); | ||
$query = '[QUERY]'; | ||
|
||
query_metadata_sample($formattedService, $query); | ||
} | ||
// [END metastore_v1_generated_DataprocMetastore_QueryMetadata_sync] |
Oops, something went wrong.