Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: introduce bigquery data policies v1 #5693

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions BigQueryDataPolicies/.OwlBot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
deep-copy-regex:
- source: /google/cloud/bigquery/datapolicies/v1beta1/.*-php/(.*)
dest: /owl-bot-staging/BigQueryDataPolicies/v1beta1/$1
- source: /google/cloud/bigquery/datapolicies/(v1|v1beta1)/.*-php/(.*)
dest: /owl-bot-staging/BigQueryDataPolicies/$1/$2
api-name: BigQueryDataPolicies
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/*
* Copyright 2022 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 bigquerydatapolicy_v1_generated_DataPolicyService_CreateDataPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\BigQuery\DataPolicies\V1\DataPolicy;
use Google\Cloud\BigQuery\DataPolicies\V1\DataPolicyServiceClient;

/**
* Creates a new data policy under a project with the given `dataPolicyId`
* (used as the display name), policy tag, and data policy type.
*
* @param string $formattedParent Resource name of the project that the data policy will belong to.
* The format is `projects/{project_number}/locations/{location_id}`. Please see
* {@see DataPolicyServiceClient::locationName()} for help formatting this field.
*/
function create_data_policy_sample(string $formattedParent): void
{
// Create a client.
$dataPolicyServiceClient = new DataPolicyServiceClient();

// Prepare any non-scalar elements to be passed along with the request.
$dataPolicy = new DataPolicy();

// Call the API and handle any network failures.
try {
/** @var DataPolicy $response */
$response = $dataPolicyServiceClient->createDataPolicy($formattedParent, $dataPolicy);
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 = DataPolicyServiceClient::locationName('[PROJECT]', '[LOCATION]');

create_data_policy_sample($formattedParent);
}
// [END bigquerydatapolicy_v1_generated_DataPolicyService_CreateDataPolicy_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
/*
* Copyright 2022 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 bigquerydatapolicy_v1_generated_DataPolicyService_DeleteDataPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\BigQuery\DataPolicies\V1\DataPolicyServiceClient;

/**
* Deletes the data policy specified by its resource name.
*
* @param string $formattedName Resource name of the data policy to delete. Format is
* `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`. Please see
* {@see DataPolicyServiceClient::dataPolicyName()} for help formatting this field.
*/
function delete_data_policy_sample(string $formattedName): void
{
// Create a client.
$dataPolicyServiceClient = new DataPolicyServiceClient();

// Call the API and handle any network failures.
try {
$dataPolicyServiceClient->deleteDataPolicy($formattedName);
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 = DataPolicyServiceClient::dataPolicyName(
'[PROJECT]',
'[LOCATION]',
'[DATA_POLICY]'
);

delete_data_policy_sample($formattedName);
}
// [END bigquerydatapolicy_v1_generated_DataPolicyService_DeleteDataPolicy_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/*
* Copyright 2022 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 bigquerydatapolicy_v1_generated_DataPolicyService_GetDataPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\BigQuery\DataPolicies\V1\DataPolicy;
use Google\Cloud\BigQuery\DataPolicies\V1\DataPolicyServiceClient;

/**
* Gets the data policy specified by its resource name.
*
* @param string $formattedName Resource name of the requested data policy. Format is
* `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`. Please see
* {@see DataPolicyServiceClient::dataPolicyName()} for help formatting this field.
*/
function get_data_policy_sample(string $formattedName): void
{
// Create a client.
$dataPolicyServiceClient = new DataPolicyServiceClient();

// Call the API and handle any network failures.
try {
/** @var DataPolicy $response */
$response = $dataPolicyServiceClient->getDataPolicy($formattedName);
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 = DataPolicyServiceClient::dataPolicyName(
'[PROJECT]',
'[LOCATION]',
'[DATA_POLICY]'
);

get_data_policy_sample($formattedName);
}
// [END bigquerydatapolicy_v1_generated_DataPolicyService_GetDataPolicy_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/*
* Copyright 2022 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 bigquerydatapolicy_v1_generated_DataPolicyService_GetIamPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\BigQuery\DataPolicies\V1\DataPolicyServiceClient;
use Google\Cloud\Iam\V1\Policy;

/**
* Gets the IAM policy for the specified data policy.
*
* @param string $resource REQUIRED: The resource for which the policy is being requested.
* See the operation documentation for the appropriate value for this field.
*/
function get_iam_policy_sample(string $resource): void
{
// Create a client.
$dataPolicyServiceClient = new DataPolicyServiceClient();

// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $dataPolicyServiceClient->getIamPolicy($resource);
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
{
$resource = '[RESOURCE]';

get_iam_policy_sample($resource);
}
// [END bigquerydatapolicy_v1_generated_DataPolicyService_GetIamPolicy_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/*
* Copyright 2022 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 bigquerydatapolicy_v1_generated_DataPolicyService_ListDataPolicies_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BigQuery\DataPolicies\V1\DataPolicy;
use Google\Cloud\BigQuery\DataPolicies\V1\DataPolicyServiceClient;

/**
* List all of the data policies in the specified parent project.
*
* @param string $formattedParent Resource name of the project for which to list data policies.
* Format is `projects/{project_number}/locations/{location_id}`. Please see
* {@see DataPolicyServiceClient::locationName()} for help formatting this field.
*/
function list_data_policies_sample(string $formattedParent): void
{
// Create a client.
$dataPolicyServiceClient = new DataPolicyServiceClient();

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

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

list_data_policies_sample($formattedParent);
}
// [END bigquerydatapolicy_v1_generated_DataPolicyService_ListDataPolicies_sync]
Loading