Skip to content
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
3 changes: 2 additions & 1 deletion Bigtable/owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
# First copy the Bigtable Admin
admin_library = Path(f"../{php.STAGING_DIR}/Bigtable/v2/Admin").resolve()

# copy gapic src and tests
# copy gapic src, samples, and tests
s.move(admin_library / f'src', 'src/Admin', merge=preserve_copyright_year)
s.move(admin_library / f'tests/Unit', 'tests/Unit/Admin', merge=preserve_copyright_year)
s.move(admin_library / f'samples', 'samples/', merge=preserve_copyright_year)

# copy proto and metadata files
s.move(admin_library / f'proto/src/Google/Cloud/Bigtable', f'src/', merge=preserve_copyright_year)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/*
* Copyright 2026 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 bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateAppProfile_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Bigtable\Admin\V2\AppProfile;
use Google\Cloud\Bigtable\Admin\V2\Client\BigtableInstanceAdminClient;
use Google\Cloud\Bigtable\Admin\V2\CreateAppProfileRequest;

/**
* Creates an app profile within an instance.
*
* @param string $formattedParent The unique name of the instance in which to create the new app
* profile. Values are of the form `projects/{project}/instances/{instance}`. Please see
* {@see BigtableInstanceAdminClient::instanceName()} for help formatting this field.
* @param string $appProfileId The ID to be used when referring to the new app profile within
* its instance, e.g., just `myprofile` rather than
* `projects/myproject/instances/myinstance/appProfiles/myprofile`.
*/
function create_app_profile_sample(string $formattedParent, string $appProfileId): void
{
// Create a client.
$bigtableInstanceAdminClient = new BigtableInstanceAdminClient();

// Prepare the request message.
$appProfile = new AppProfile();
$request = (new CreateAppProfileRequest())
->setParent($formattedParent)
->setAppProfileId($appProfileId)
->setAppProfile($appProfile);

// Call the API and handle any network failures.
try {
/** @var AppProfile $response */
$response = $bigtableInstanceAdminClient->createAppProfile($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 = BigtableInstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]');
$appProfileId = '[APP_PROFILE_ID]';

create_app_profile_sample($formattedParent, $appProfileId);
}
// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateAppProfile_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php
/*
* Copyright 2026 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 bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateCluster_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Bigtable\Admin\V2\Client\BigtableInstanceAdminClient;
use Google\Cloud\Bigtable\Admin\V2\Cluster;
use Google\Cloud\Bigtable\Admin\V2\CreateClusterRequest;
use Google\Rpc\Status;

/**
* Creates a cluster within an instance.
*
* Note that exactly one of Cluster.serve_nodes and
* Cluster.cluster_config.cluster_autoscaling_config can be set. If
* serve_nodes is set to non-zero, then the cluster is manually scaled. If
* cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is
* enabled.
*
* @param string $formattedParent The unique name of the instance in which to create the new
* cluster. Values are of the form `projects/{project}/instances/{instance}`. Please see
* {@see BigtableInstanceAdminClient::instanceName()} for help formatting this field.
* @param string $clusterId The ID to be used when referring to the new cluster within its
* instance, e.g., just `mycluster` rather than
* `projects/myproject/instances/myinstance/clusters/mycluster`.
*/
function create_cluster_sample(string $formattedParent, string $clusterId): void
{
// Create a client.
$bigtableInstanceAdminClient = new BigtableInstanceAdminClient();

// Prepare the request message.
$cluster = new Cluster();
$request = (new CreateClusterRequest())
->setParent($formattedParent)
->setClusterId($clusterId)
->setCluster($cluster);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $bigtableInstanceAdminClient->createCluster($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var Cluster $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
{
$formattedParent = BigtableInstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]');
$clusterId = '[CLUSTER_ID]';

create_cluster_sample($formattedParent, $clusterId);
}
// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateCluster_sync]
107 changes: 107 additions & 0 deletions Bigtable/samples/V2/BigtableInstanceAdminClient/create_instance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php
/*
* Copyright 2026 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 bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateInstance_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Bigtable\Admin\V2\Client\BigtableInstanceAdminClient;
use Google\Cloud\Bigtable\Admin\V2\CreateInstanceRequest;
use Google\Cloud\Bigtable\Admin\V2\Instance;
use Google\Rpc\Status;

/**
* Create an instance within a project.
*
* Note that exactly one of Cluster.serve_nodes and
* Cluster.cluster_config.cluster_autoscaling_config can be set. If
* serve_nodes is set to non-zero, then the cluster is manually scaled. If
* cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is
* enabled.
*
* @param string $formattedParent The unique name of the project in which to create the new
* instance. Values are of the form `projects/{project}`. Please see
* {@see BigtableInstanceAdminClient::projectName()} for help formatting this field.
* @param string $instanceId The ID to be used when referring to the new instance within its
* project, e.g., just `myinstance` rather than
* `projects/myproject/instances/myinstance`.
* @param string $instanceDisplayName The descriptive name for this instance as it appears in UIs.
* Can be changed at any time, but should be kept globally unique
* to avoid confusion.
*/
function create_instance_sample(
string $formattedParent,
string $instanceId,
string $instanceDisplayName
): void {
// Create a client.
$bigtableInstanceAdminClient = new BigtableInstanceAdminClient();

// Prepare the request message.
$instance = (new Instance())
->setDisplayName($instanceDisplayName);
$clusters = [];
$request = (new CreateInstanceRequest())
->setParent($formattedParent)
->setInstanceId($instanceId)
->setInstance($instance)
->setClusters($clusters);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $bigtableInstanceAdminClient->createInstance($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var Instance $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
{
$formattedParent = BigtableInstanceAdminClient::projectName('[PROJECT]');
$instanceId = '[INSTANCE_ID]';
$instanceDisplayName = '[DISPLAY_NAME]';

create_instance_sample($formattedParent, $instanceId, $instanceDisplayName);
}
// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateInstance_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php
/*
* Copyright 2026 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 bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateLogicalView_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Bigtable\Admin\V2\Client\BigtableInstanceAdminClient;
use Google\Cloud\Bigtable\Admin\V2\CreateLogicalViewRequest;
use Google\Cloud\Bigtable\Admin\V2\LogicalView;
use Google\Rpc\Status;

/**
* Creates a logical view within an instance.
*
* @param string $formattedParent The parent instance where this logical view will be created.
* Format: `projects/{project}/instances/{instance}`. Please see
* {@see BigtableInstanceAdminClient::instanceName()} for help formatting this field.
* @param string $logicalViewId The ID to use for the logical view, which will become the final
* component of the logical view's resource name.
* @param string $logicalViewQuery The logical view's select query.
*/
function create_logical_view_sample(
string $formattedParent,
string $logicalViewId,
string $logicalViewQuery
): void {
// Create a client.
$bigtableInstanceAdminClient = new BigtableInstanceAdminClient();

// Prepare the request message.
$logicalView = (new LogicalView())
->setQuery($logicalViewQuery);
$request = (new CreateLogicalViewRequest())
->setParent($formattedParent)
->setLogicalViewId($logicalViewId)
->setLogicalView($logicalView);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $bigtableInstanceAdminClient->createLogicalView($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var LogicalView $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
{
$formattedParent = BigtableInstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]');
$logicalViewId = '[LOGICAL_VIEW_ID]';
$logicalViewQuery = '[QUERY]';

create_logical_view_sample($formattedParent, $logicalViewId, $logicalViewQuery);
}
// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateLogicalView_sync]
Loading
Loading