From 13793eb19d1152ed19ce771f8b29189275319d8d Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 25 Mar 2026 20:49:38 +0000 Subject: [PATCH] fix(Bigtable): ensure samples are generated for admin clients --- Bigtable/owlbot.py | 3 +- .../create_app_profile.php | 79 ++++++++++++ .../create_cluster.php | 97 +++++++++++++++ .../create_instance.php | 107 ++++++++++++++++ .../create_logical_view.php | 96 +++++++++++++++ .../create_materialized_view.php | 96 +++++++++++++++ .../delete_app_profile.php | 78 ++++++++++++ .../delete_cluster.php | 70 +++++++++++ .../delete_instance.php | 70 +++++++++++ .../delete_logical_view.php | 75 ++++++++++++ .../delete_materialized_view.php | 75 ++++++++++++ .../get_app_profile.php | 76 ++++++++++++ .../get_cluster.php | 72 +++++++++++ .../get_iam_policy.php | 72 +++++++++++ .../get_instance.php | 72 +++++++++++ .../get_logical_view.php | 76 ++++++++++++ .../get_materialized_view.php | 77 ++++++++++++ .../list_app_profiles.php | 80 ++++++++++++ .../list_clusters.php | 75 ++++++++++++ .../list_hot_tablets.php | 79 ++++++++++++ .../list_instances.php | 72 +++++++++++ .../list_logical_views.php | 78 ++++++++++++ .../list_materialized_views.php | 78 ++++++++++++ .../partial_update_cluster.php | 85 +++++++++++++ .../partial_update_instance.php | 90 ++++++++++++++ .../set_iam_policy.php | 74 +++++++++++ .../test_iam_permissions.php | 78 ++++++++++++ .../update_app_profile.php | 74 +++++++++++ .../update_cluster.php | 91 ++++++++++++++ .../update_instance.php | 83 +++++++++++++ .../update_logical_view.php | 84 +++++++++++++ .../update_materialized_view.php | 84 +++++++++++++ .../check_consistency.php | 78 ++++++++++++ .../BigtableTableAdminClient/copy_backup.php | 115 ++++++++++++++++++ .../create_authorized_view.php | 93 ++++++++++++++ .../create_backup.php | 113 +++++++++++++++++ .../create_schema_bundle.php | 91 ++++++++++++++ .../BigtableTableAdminClient/create_table.php | 81 ++++++++++++ .../create_table_from_snapshot.php | 110 +++++++++++++++++ .../delete_authorized_view.php | 76 ++++++++++++ .../delete_backup.php | 76 ++++++++++++ .../delete_schema_bundle.php | 76 ++++++++++++ .../delete_snapshot.php | 82 +++++++++++++ .../BigtableTableAdminClient/delete_table.php | 71 +++++++++++ .../drop_row_range.php | 73 +++++++++++ .../generate_consistency_token.php | 76 ++++++++++++ .../get_authorized_view.php | 78 ++++++++++++ .../BigtableTableAdminClient/get_backup.php | 78 ++++++++++++ .../get_iam_policy.php | 73 +++++++++++ .../get_schema_bundle.php | 78 ++++++++++++ .../BigtableTableAdminClient/get_snapshot.php | 84 +++++++++++++ .../V2/BigtableTableAdminClient/get_table.php | 73 +++++++++++ .../list_authorized_views.php | 78 ++++++++++++ .../BigtableTableAdminClient/list_backups.php | 80 ++++++++++++ .../list_schema_bundles.php | 78 ++++++++++++ .../list_snapshots.php | 86 +++++++++++++ .../BigtableTableAdminClient/list_tables.php | 77 ++++++++++++ .../modify_column_families.php | 79 ++++++++++++ .../restore_table.php | 96 +++++++++++++++ .../set_iam_policy.php | 74 +++++++++++ .../snapshot_table.php | 107 ++++++++++++++++ .../test_iam_permissions.php | 79 ++++++++++++ .../undelete_table.php | 85 +++++++++++++ .../update_authorized_view.php | 71 +++++++++++ .../update_backup.php | 80 ++++++++++++ .../update_schema_bundle.php | 71 +++++++++++ .../BigtableTableAdminClient/update_table.php | 74 +++++++++++ 67 files changed, 5385 insertions(+), 1 deletion(-) create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/create_app_profile.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/create_cluster.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/create_instance.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/create_logical_view.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/create_materialized_view.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/delete_app_profile.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/delete_cluster.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/delete_instance.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/delete_logical_view.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/delete_materialized_view.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/get_app_profile.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/get_cluster.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/get_iam_policy.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/get_instance.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/get_logical_view.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/get_materialized_view.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/list_app_profiles.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/list_clusters.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/list_hot_tablets.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/list_instances.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/list_logical_views.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/list_materialized_views.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/partial_update_cluster.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/partial_update_instance.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/set_iam_policy.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/test_iam_permissions.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/update_app_profile.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/update_cluster.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/update_instance.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/update_logical_view.php create mode 100644 Bigtable/samples/V2/BigtableInstanceAdminClient/update_materialized_view.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/check_consistency.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/copy_backup.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/create_authorized_view.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/create_backup.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/create_schema_bundle.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/create_table.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/create_table_from_snapshot.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/delete_authorized_view.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/delete_backup.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/delete_schema_bundle.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/delete_snapshot.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/delete_table.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/drop_row_range.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/generate_consistency_token.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/get_authorized_view.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/get_backup.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/get_iam_policy.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/get_schema_bundle.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/get_snapshot.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/get_table.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/list_authorized_views.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/list_backups.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/list_schema_bundles.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/list_snapshots.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/list_tables.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/modify_column_families.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/restore_table.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/set_iam_policy.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/snapshot_table.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/test_iam_permissions.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/undelete_table.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/update_authorized_view.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/update_backup.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/update_schema_bundle.php create mode 100644 Bigtable/samples/V2/BigtableTableAdminClient/update_table.php diff --git a/Bigtable/owlbot.py b/Bigtable/owlbot.py index a770b3d174e9..00fd9d596e64 100644 --- a/Bigtable/owlbot.py +++ b/Bigtable/owlbot.py @@ -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) diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/create_app_profile.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/create_app_profile.php new file mode 100644 index 000000000000..744a7cb0bf2b --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/create_app_profile.php @@ -0,0 +1,79 @@ +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] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/create_cluster.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/create_cluster.php new file mode 100644 index 000000000000..1d27410e8d63 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/create_cluster.php @@ -0,0 +1,97 @@ +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] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/create_instance.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/create_instance.php new file mode 100644 index 000000000000..62082d3b982c --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/create_instance.php @@ -0,0 +1,107 @@ +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] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/create_logical_view.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/create_logical_view.php new file mode 100644 index 000000000000..d31695d623b6 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/create_logical_view.php @@ -0,0 +1,96 @@ +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] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/create_materialized_view.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/create_materialized_view.php new file mode 100644 index 000000000000..468f68efd44e --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/create_materialized_view.php @@ -0,0 +1,96 @@ +setQuery($materializedViewQuery); + $request = (new CreateMaterializedViewRequest()) + ->setParent($formattedParent) + ->setMaterializedViewId($materializedViewId) + ->setMaterializedView($materializedView); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableInstanceAdminClient->createMaterializedView($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var MaterializedView $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]'); + $materializedViewId = '[MATERIALIZED_VIEW_ID]'; + $materializedViewQuery = '[QUERY]'; + + create_materialized_view_sample($formattedParent, $materializedViewId, $materializedViewQuery); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateMaterializedView_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_app_profile.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_app_profile.php new file mode 100644 index 000000000000..b16f879f7d8f --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_app_profile.php @@ -0,0 +1,78 @@ +setName($formattedName) + ->setIgnoreWarnings($ignoreWarnings); + + // Call the API and handle any network failures. + try { + $bigtableInstanceAdminClient->deleteAppProfile($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 = BigtableInstanceAdminClient::appProfileName( + '[PROJECT]', + '[INSTANCE]', + '[APP_PROFILE]' + ); + $ignoreWarnings = false; + + delete_app_profile_sample($formattedName, $ignoreWarnings); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteAppProfile_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_cluster.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_cluster.php new file mode 100644 index 000000000000..7f2ee487f57e --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_cluster.php @@ -0,0 +1,70 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $bigtableInstanceAdminClient->deleteCluster($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 = BigtableInstanceAdminClient::clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); + + delete_cluster_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteCluster_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_instance.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_instance.php new file mode 100644 index 000000000000..d203cfce54fa --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_instance.php @@ -0,0 +1,70 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $bigtableInstanceAdminClient->deleteInstance($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 = BigtableInstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + delete_instance_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteInstance_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_logical_view.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_logical_view.php new file mode 100644 index 000000000000..a5853c1a1e2b --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_logical_view.php @@ -0,0 +1,75 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $bigtableInstanceAdminClient->deleteLogicalView($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 = BigtableInstanceAdminClient::logicalViewName( + '[PROJECT]', + '[INSTANCE]', + '[LOGICAL_VIEW]' + ); + + delete_logical_view_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteLogicalView_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_materialized_view.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_materialized_view.php new file mode 100644 index 000000000000..e861dbdad22c --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/delete_materialized_view.php @@ -0,0 +1,75 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $bigtableInstanceAdminClient->deleteMaterializedView($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 = BigtableInstanceAdminClient::materializedViewName( + '[PROJECT]', + '[INSTANCE]', + '[MATERIALIZED_VIEW]' + ); + + delete_materialized_view_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteMaterializedView_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/get_app_profile.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_app_profile.php new file mode 100644 index 000000000000..a2887eef350a --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_app_profile.php @@ -0,0 +1,76 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var AppProfile $response */ + $response = $bigtableInstanceAdminClient->getAppProfile($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 = BigtableInstanceAdminClient::appProfileName( + '[PROJECT]', + '[INSTANCE]', + '[APP_PROFILE]' + ); + + get_app_profile_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_GetAppProfile_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/get_cluster.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_cluster.php new file mode 100644 index 000000000000..96097273c073 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_cluster.php @@ -0,0 +1,72 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Cluster $response */ + $response = $bigtableInstanceAdminClient->getCluster($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 = BigtableInstanceAdminClient::clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); + + get_cluster_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_GetCluster_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/get_iam_policy.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_iam_policy.php new file mode 100644 index 000000000000..17ca22f1ea7f --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_iam_policy.php @@ -0,0 +1,72 @@ +setResource($resource); + + // Call the API and handle any network failures. + try { + /** @var Policy $response */ + $response = $bigtableInstanceAdminClient->getIamPolicy($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 +{ + $resource = '[RESOURCE]'; + + get_iam_policy_sample($resource); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_GetIamPolicy_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/get_instance.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_instance.php new file mode 100644 index 000000000000..c309298fac75 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_instance.php @@ -0,0 +1,72 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Instance $response */ + $response = $bigtableInstanceAdminClient->getInstance($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 = BigtableInstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + get_instance_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_GetInstance_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/get_logical_view.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_logical_view.php new file mode 100644 index 000000000000..e5e8383687ff --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_logical_view.php @@ -0,0 +1,76 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var LogicalView $response */ + $response = $bigtableInstanceAdminClient->getLogicalView($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 = BigtableInstanceAdminClient::logicalViewName( + '[PROJECT]', + '[INSTANCE]', + '[LOGICAL_VIEW]' + ); + + get_logical_view_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_GetLogicalView_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/get_materialized_view.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_materialized_view.php new file mode 100644 index 000000000000..97636f2e4935 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/get_materialized_view.php @@ -0,0 +1,77 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var MaterializedView $response */ + $response = $bigtableInstanceAdminClient->getMaterializedView($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 = BigtableInstanceAdminClient::materializedViewName( + '[PROJECT]', + '[INSTANCE]', + '[MATERIALIZED_VIEW]' + ); + + get_materialized_view_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_GetMaterializedView_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/list_app_profiles.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_app_profiles.php new file mode 100644 index 000000000000..50ec536ac823 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_app_profiles.php @@ -0,0 +1,80 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $bigtableInstanceAdminClient->listAppProfiles($request); + + /** @var AppProfile $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 = BigtableInstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + list_app_profiles_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_ListAppProfiles_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/list_clusters.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_clusters.php new file mode 100644 index 000000000000..2a14a470e2fa --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_clusters.php @@ -0,0 +1,75 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var ListClustersResponse $response */ + $response = $bigtableInstanceAdminClient->listClusters($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]'); + + list_clusters_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_ListClusters_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/list_hot_tablets.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_hot_tablets.php new file mode 100644 index 000000000000..fc16cd170564 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_hot_tablets.php @@ -0,0 +1,79 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $bigtableInstanceAdminClient->listHotTablets($request); + + /** @var HotTablet $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 = BigtableInstanceAdminClient::clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); + + list_hot_tablets_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_ListHotTablets_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/list_instances.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_instances.php new file mode 100644 index 000000000000..3282496dfc9d --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_instances.php @@ -0,0 +1,72 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var ListInstancesResponse $response */ + $response = $bigtableInstanceAdminClient->listInstances($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::projectName('[PROJECT]'); + + list_instances_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_ListInstances_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/list_logical_views.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_logical_views.php new file mode 100644 index 000000000000..901240be505c --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_logical_views.php @@ -0,0 +1,78 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $bigtableInstanceAdminClient->listLogicalViews($request); + + /** @var LogicalView $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 = BigtableInstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + list_logical_views_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_ListLogicalViews_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/list_materialized_views.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_materialized_views.php new file mode 100644 index 000000000000..5ad8dad74387 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/list_materialized_views.php @@ -0,0 +1,78 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $bigtableInstanceAdminClient->listMaterializedViews($request); + + /** @var MaterializedView $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 = BigtableInstanceAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + list_materialized_views_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_ListMaterializedViews_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/partial_update_cluster.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/partial_update_cluster.php new file mode 100644 index 000000000000..ad0be3d66ea9 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/partial_update_cluster.php @@ -0,0 +1,85 @@ +setCluster($cluster) + ->setUpdateMask($updateMask); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableInstanceAdminClient->partialUpdateCluster($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()); + } +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_PartialUpdateCluster_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/partial_update_instance.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/partial_update_instance.php new file mode 100644 index 000000000000..9f5a6d5303d6 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/partial_update_instance.php @@ -0,0 +1,90 @@ +setDisplayName($instanceDisplayName); + $updateMask = new FieldMask(); + $request = (new PartialUpdateInstanceRequest()) + ->setInstance($instance) + ->setUpdateMask($updateMask); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableInstanceAdminClient->partialUpdateInstance($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 +{ + $instanceDisplayName = '[DISPLAY_NAME]'; + + partial_update_instance_sample($instanceDisplayName); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_PartialUpdateInstance_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/set_iam_policy.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/set_iam_policy.php new file mode 100644 index 000000000000..da536e9b47f9 --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/set_iam_policy.php @@ -0,0 +1,74 @@ +setResource($resource) + ->setPolicy($policy); + + // Call the API and handle any network failures. + try { + /** @var Policy $response */ + $response = $bigtableInstanceAdminClient->setIamPolicy($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 +{ + $resource = '[RESOURCE]'; + + set_iam_policy_sample($resource); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_SetIamPolicy_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/test_iam_permissions.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/test_iam_permissions.php new file mode 100644 index 000000000000..7edfde9e90ef --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/test_iam_permissions.php @@ -0,0 +1,78 @@ +setResource($resource) + ->setPermissions($permissions); + + // Call the API and handle any network failures. + try { + /** @var TestIamPermissionsResponse $response */ + $response = $bigtableInstanceAdminClient->testIamPermissions($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 +{ + $resource = '[RESOURCE]'; + $permissionsElement = '[PERMISSIONS]'; + + test_iam_permissions_sample($resource, $permissionsElement); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_TestIamPermissions_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/update_app_profile.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/update_app_profile.php new file mode 100644 index 000000000000..f028673d8c8c --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/update_app_profile.php @@ -0,0 +1,74 @@ +setAppProfile($appProfile) + ->setUpdateMask($updateMask); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableInstanceAdminClient->updateAppProfile($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var AppProfile $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()); + } +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateAppProfile_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/update_cluster.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/update_cluster.php new file mode 100644 index 000000000000..4db75150127e --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/update_cluster.php @@ -0,0 +1,91 @@ +setName($name) + ->setServeNodes($serveNodes); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableInstanceAdminClient->updateCluster($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 +{ + $name = '[NAME]'; + $serveNodes = 0; + + update_cluster_sample($name, $serveNodes); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateCluster_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/update_instance.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/update_instance.php new file mode 100644 index 000000000000..65a8127b9b4d --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/update_instance.php @@ -0,0 +1,83 @@ +setName($name) + ->setDisplayName($displayName) + ->setType($type) + ->setLabels($labels); + + // Call the API and handle any network failures. + try { + /** @var Instance $response */ + $response = $bigtableInstanceAdminClient->updateInstance($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 +{ + $name = '[NAME]'; + $displayName = '[DISPLAY_NAME]'; + $type = Type::TYPE_UNSPECIFIED; + + update_instance_sample($name, $displayName, $type); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateInstance_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/update_logical_view.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/update_logical_view.php new file mode 100644 index 000000000000..49ea82c9532a --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/update_logical_view.php @@ -0,0 +1,84 @@ +setQuery($logicalViewQuery); + $request = (new UpdateLogicalViewRequest()) + ->setLogicalView($logicalView); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableInstanceAdminClient->updateLogicalView($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 +{ + $logicalViewQuery = '[QUERY]'; + + update_logical_view_sample($logicalViewQuery); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateLogicalView_sync] diff --git a/Bigtable/samples/V2/BigtableInstanceAdminClient/update_materialized_view.php b/Bigtable/samples/V2/BigtableInstanceAdminClient/update_materialized_view.php new file mode 100644 index 000000000000..205f4dc4804a --- /dev/null +++ b/Bigtable/samples/V2/BigtableInstanceAdminClient/update_materialized_view.php @@ -0,0 +1,84 @@ +setQuery($materializedViewQuery); + $request = (new UpdateMaterializedViewRequest()) + ->setMaterializedView($materializedView); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableInstanceAdminClient->updateMaterializedView($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var MaterializedView $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 +{ + $materializedViewQuery = '[QUERY]'; + + update_materialized_view_sample($materializedViewQuery); +} +// [END bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateMaterializedView_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/check_consistency.php b/Bigtable/samples/V2/BigtableTableAdminClient/check_consistency.php new file mode 100644 index 000000000000..989cc64c0167 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/check_consistency.php @@ -0,0 +1,78 @@ +setName($formattedName) + ->setConsistencyToken($consistencyToken); + + // Call the API and handle any network failures. + try { + /** @var CheckConsistencyResponse $response */ + $response = $bigtableTableAdminClient->checkConsistency($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 = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + $consistencyToken = '[CONSISTENCY_TOKEN]'; + + check_consistency_sample($formattedName, $consistencyToken); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_CheckConsistency_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/copy_backup.php b/Bigtable/samples/V2/BigtableTableAdminClient/copy_backup.php new file mode 100644 index 000000000000..984cef9fa2cf --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/copy_backup.php @@ -0,0 +1,115 @@ +/instances//clusters//backups/`. Please see + * {@see BigtableTableAdminClient::backupName()} for help formatting this field. + */ +function copy_backup_sample( + string $formattedParent, + string $backupId, + string $formattedSourceBackup +): void { + // Create a client. + $bigtableTableAdminClient = new BigtableTableAdminClient(); + + // Prepare the request message. + $expireTime = new Timestamp(); + $request = (new CopyBackupRequest()) + ->setParent($formattedParent) + ->setBackupId($backupId) + ->setSourceBackup($formattedSourceBackup) + ->setExpireTime($expireTime); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->copyBackup($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Backup $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 = BigtableTableAdminClient::clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); + $backupId = '[BACKUP_ID]'; + $formattedSourceBackup = BigtableTableAdminClient::backupName( + '[PROJECT]', + '[INSTANCE]', + '[CLUSTER]', + '[BACKUP]' + ); + + copy_backup_sample($formattedParent, $backupId, $formattedSourceBackup); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_CopyBackup_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/create_authorized_view.php b/Bigtable/samples/V2/BigtableTableAdminClient/create_authorized_view.php new file mode 100644 index 000000000000..fdf560b122c0 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/create_authorized_view.php @@ -0,0 +1,93 @@ +setParent($formattedParent) + ->setAuthorizedViewId($authorizedViewId) + ->setAuthorizedView($authorizedView); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->createAuthorizedView($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var AuthorizedView $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 = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + $authorizedViewId = '[AUTHORIZED_VIEW_ID]'; + + create_authorized_view_sample($formattedParent, $authorizedViewId); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_CreateAuthorizedView_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/create_backup.php b/Bigtable/samples/V2/BigtableTableAdminClient/create_backup.php new file mode 100644 index 000000000000..e72b3f58b9e4 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/create_backup.php @@ -0,0 +1,113 @@ +setSourceTable($backupSourceTable) + ->setExpireTime($backupExpireTime); + $request = (new CreateBackupRequest()) + ->setParent($formattedParent) + ->setBackupId($backupId) + ->setBackup($backup); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->createBackup($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Backup $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 = BigtableTableAdminClient::clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); + $backupId = '[BACKUP_ID]'; + $backupSourceTable = '[SOURCE_TABLE]'; + + create_backup_sample($formattedParent, $backupId, $backupSourceTable); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_CreateBackup_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/create_schema_bundle.php b/Bigtable/samples/V2/BigtableTableAdminClient/create_schema_bundle.php new file mode 100644 index 000000000000..91d252913315 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/create_schema_bundle.php @@ -0,0 +1,91 @@ +setParent($formattedParent) + ->setSchemaBundleId($schemaBundleId) + ->setSchemaBundle($schemaBundle); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->createSchemaBundle($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var SchemaBundle $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 = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + $schemaBundleId = '[SCHEMA_BUNDLE_ID]'; + + create_schema_bundle_sample($formattedParent, $schemaBundleId); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_CreateSchemaBundle_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/create_table.php b/Bigtable/samples/V2/BigtableTableAdminClient/create_table.php new file mode 100644 index 000000000000..f027483edc1c --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/create_table.php @@ -0,0 +1,81 @@ +setParent($formattedParent) + ->setTableId($tableId) + ->setTable($table); + + // Call the API and handle any network failures. + try { + /** @var Table $response */ + $response = $bigtableTableAdminClient->createTable($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 = BigtableTableAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + $tableId = '[TABLE_ID]'; + + create_table_sample($formattedParent, $tableId); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_CreateTable_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/create_table_from_snapshot.php b/Bigtable/samples/V2/BigtableTableAdminClient/create_table_from_snapshot.php new file mode 100644 index 000000000000..1f091cff8e36 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/create_table_from_snapshot.php @@ -0,0 +1,110 @@ +setParent($formattedParent) + ->setTableId($tableId) + ->setSourceSnapshot($formattedSourceSnapshot); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->createTableFromSnapshot($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Table $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 = BigtableTableAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + $tableId = '[TABLE_ID]'; + $formattedSourceSnapshot = BigtableTableAdminClient::snapshotName( + '[PROJECT]', + '[INSTANCE]', + '[CLUSTER]', + '[SNAPSHOT]' + ); + + create_table_from_snapshot_sample($formattedParent, $tableId, $formattedSourceSnapshot); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_CreateTableFromSnapshot_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/delete_authorized_view.php b/Bigtable/samples/V2/BigtableTableAdminClient/delete_authorized_view.php new file mode 100644 index 000000000000..00af6cc8371f --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/delete_authorized_view.php @@ -0,0 +1,76 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $bigtableTableAdminClient->deleteAuthorizedView($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 = BigtableTableAdminClient::authorizedViewName( + '[PROJECT]', + '[INSTANCE]', + '[TABLE]', + '[AUTHORIZED_VIEW]' + ); + + delete_authorized_view_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_DeleteAuthorizedView_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/delete_backup.php b/Bigtable/samples/V2/BigtableTableAdminClient/delete_backup.php new file mode 100644 index 000000000000..1295399b40d4 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/delete_backup.php @@ -0,0 +1,76 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $bigtableTableAdminClient->deleteBackup($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 = BigtableTableAdminClient::backupName( + '[PROJECT]', + '[INSTANCE]', + '[CLUSTER]', + '[BACKUP]' + ); + + delete_backup_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_DeleteBackup_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/delete_schema_bundle.php b/Bigtable/samples/V2/BigtableTableAdminClient/delete_schema_bundle.php new file mode 100644 index 000000000000..4036441c18c4 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/delete_schema_bundle.php @@ -0,0 +1,76 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $bigtableTableAdminClient->deleteSchemaBundle($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 = BigtableTableAdminClient::schemaBundleName( + '[PROJECT]', + '[INSTANCE]', + '[TABLE]', + '[SCHEMA_BUNDLE]' + ); + + delete_schema_bundle_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_DeleteSchemaBundle_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/delete_snapshot.php b/Bigtable/samples/V2/BigtableTableAdminClient/delete_snapshot.php new file mode 100644 index 000000000000..b72e1aba3e28 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/delete_snapshot.php @@ -0,0 +1,82 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $bigtableTableAdminClient->deleteSnapshot($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 = BigtableTableAdminClient::snapshotName( + '[PROJECT]', + '[INSTANCE]', + '[CLUSTER]', + '[SNAPSHOT]' + ); + + delete_snapshot_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_DeleteSnapshot_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/delete_table.php b/Bigtable/samples/V2/BigtableTableAdminClient/delete_table.php new file mode 100644 index 000000000000..39413f4935b7 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/delete_table.php @@ -0,0 +1,71 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $bigtableTableAdminClient->deleteTable($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 = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + + delete_table_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_DeleteTable_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/drop_row_range.php b/Bigtable/samples/V2/BigtableTableAdminClient/drop_row_range.php new file mode 100644 index 000000000000..a10f821ec8b2 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/drop_row_range.php @@ -0,0 +1,73 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + $bigtableTableAdminClient->dropRowRange($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 = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + + drop_row_range_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_DropRowRange_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/generate_consistency_token.php b/Bigtable/samples/V2/BigtableTableAdminClient/generate_consistency_token.php new file mode 100644 index 000000000000..a20dd630f22f --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/generate_consistency_token.php @@ -0,0 +1,76 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var GenerateConsistencyTokenResponse $response */ + $response = $bigtableTableAdminClient->generateConsistencyToken($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 = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + + generate_consistency_token_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_GenerateConsistencyToken_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/get_authorized_view.php b/Bigtable/samples/V2/BigtableTableAdminClient/get_authorized_view.php new file mode 100644 index 000000000000..47c3aab01f0f --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/get_authorized_view.php @@ -0,0 +1,78 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var AuthorizedView $response */ + $response = $bigtableTableAdminClient->getAuthorizedView($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 = BigtableTableAdminClient::authorizedViewName( + '[PROJECT]', + '[INSTANCE]', + '[TABLE]', + '[AUTHORIZED_VIEW]' + ); + + get_authorized_view_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_GetAuthorizedView_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/get_backup.php b/Bigtable/samples/V2/BigtableTableAdminClient/get_backup.php new file mode 100644 index 000000000000..410abe345856 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/get_backup.php @@ -0,0 +1,78 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Backup $response */ + $response = $bigtableTableAdminClient->getBackup($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 = BigtableTableAdminClient::backupName( + '[PROJECT]', + '[INSTANCE]', + '[CLUSTER]', + '[BACKUP]' + ); + + get_backup_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_GetBackup_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/get_iam_policy.php b/Bigtable/samples/V2/BigtableTableAdminClient/get_iam_policy.php new file mode 100644 index 000000000000..d6af14bcb52e --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/get_iam_policy.php @@ -0,0 +1,73 @@ +setResource($resource); + + // Call the API and handle any network failures. + try { + /** @var Policy $response */ + $response = $bigtableTableAdminClient->getIamPolicy($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 +{ + $resource = '[RESOURCE]'; + + get_iam_policy_sample($resource); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_GetIamPolicy_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/get_schema_bundle.php b/Bigtable/samples/V2/BigtableTableAdminClient/get_schema_bundle.php new file mode 100644 index 000000000000..fa8a213c2844 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/get_schema_bundle.php @@ -0,0 +1,78 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var SchemaBundle $response */ + $response = $bigtableTableAdminClient->getSchemaBundle($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 = BigtableTableAdminClient::schemaBundleName( + '[PROJECT]', + '[INSTANCE]', + '[TABLE]', + '[SCHEMA_BUNDLE]' + ); + + get_schema_bundle_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_GetSchemaBundle_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/get_snapshot.php b/Bigtable/samples/V2/BigtableTableAdminClient/get_snapshot.php new file mode 100644 index 000000000000..1735de5824a2 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/get_snapshot.php @@ -0,0 +1,84 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Snapshot $response */ + $response = $bigtableTableAdminClient->getSnapshot($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 = BigtableTableAdminClient::snapshotName( + '[PROJECT]', + '[INSTANCE]', + '[CLUSTER]', + '[SNAPSHOT]' + ); + + get_snapshot_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_GetSnapshot_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/get_table.php b/Bigtable/samples/V2/BigtableTableAdminClient/get_table.php new file mode 100644 index 000000000000..48308955b255 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/get_table.php @@ -0,0 +1,73 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var Table $response */ + $response = $bigtableTableAdminClient->getTable($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 = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + + get_table_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_GetTable_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/list_authorized_views.php b/Bigtable/samples/V2/BigtableTableAdminClient/list_authorized_views.php new file mode 100644 index 000000000000..825af93b1d1d --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/list_authorized_views.php @@ -0,0 +1,78 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $bigtableTableAdminClient->listAuthorizedViews($request); + + /** @var AuthorizedView $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 = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + + list_authorized_views_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_ListAuthorizedViews_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/list_backups.php b/Bigtable/samples/V2/BigtableTableAdminClient/list_backups.php new file mode 100644 index 000000000000..0e95887d9886 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/list_backups.php @@ -0,0 +1,80 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $bigtableTableAdminClient->listBackups($request); + + /** @var Backup $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 = BigtableTableAdminClient::clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); + + list_backups_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_ListBackups_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/list_schema_bundles.php b/Bigtable/samples/V2/BigtableTableAdminClient/list_schema_bundles.php new file mode 100644 index 000000000000..172546d31a27 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/list_schema_bundles.php @@ -0,0 +1,78 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $bigtableTableAdminClient->listSchemaBundles($request); + + /** @var SchemaBundle $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 = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + + list_schema_bundles_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_ListSchemaBundles_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/list_snapshots.php b/Bigtable/samples/V2/BigtableTableAdminClient/list_snapshots.php new file mode 100644 index 000000000000..f82d2f9a1803 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/list_snapshots.php @@ -0,0 +1,86 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $bigtableTableAdminClient->listSnapshots($request); + + /** @var Snapshot $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 = BigtableTableAdminClient::clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); + + list_snapshots_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_ListSnapshots_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/list_tables.php b/Bigtable/samples/V2/BigtableTableAdminClient/list_tables.php new file mode 100644 index 000000000000..dbc5a9dc47c4 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/list_tables.php @@ -0,0 +1,77 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $bigtableTableAdminClient->listTables($request); + + /** @var Table $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 = BigtableTableAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + + list_tables_sample($formattedParent); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_ListTables_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/modify_column_families.php b/Bigtable/samples/V2/BigtableTableAdminClient/modify_column_families.php new file mode 100644 index 000000000000..f66169868020 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/modify_column_families.php @@ -0,0 +1,79 @@ +setName($formattedName) + ->setModifications($modifications); + + // Call the API and handle any network failures. + try { + /** @var Table $response */ + $response = $bigtableTableAdminClient->modifyColumnFamilies($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 = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + + modify_column_families_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_ModifyColumnFamilies_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/restore_table.php b/Bigtable/samples/V2/BigtableTableAdminClient/restore_table.php new file mode 100644 index 000000000000..47790c3eba5a --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/restore_table.php @@ -0,0 +1,96 @@ +/instances/`. Please see + * {@see BigtableTableAdminClient::instanceName()} for help formatting this field. + * @param string $tableId The id of the table to create and restore to. This + * table must not already exist. The `table_id` appended to + * `parent` forms the full table name of the form + * `projects//instances//tables/`. + */ +function restore_table_sample(string $formattedParent, string $tableId): void +{ + // Create a client. + $bigtableTableAdminClient = new BigtableTableAdminClient(); + + // Prepare the request message. + $request = (new RestoreTableRequest()) + ->setParent($formattedParent) + ->setTableId($tableId); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->restoreTable($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Table $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 = BigtableTableAdminClient::instanceName('[PROJECT]', '[INSTANCE]'); + $tableId = '[TABLE_ID]'; + + restore_table_sample($formattedParent, $tableId); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_RestoreTable_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/set_iam_policy.php b/Bigtable/samples/V2/BigtableTableAdminClient/set_iam_policy.php new file mode 100644 index 000000000000..41733ffdbca2 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/set_iam_policy.php @@ -0,0 +1,74 @@ +setResource($resource) + ->setPolicy($policy); + + // Call the API and handle any network failures. + try { + /** @var Policy $response */ + $response = $bigtableTableAdminClient->setIamPolicy($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 +{ + $resource = '[RESOURCE]'; + + set_iam_policy_sample($resource); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_SetIamPolicy_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/snapshot_table.php b/Bigtable/samples/V2/BigtableTableAdminClient/snapshot_table.php new file mode 100644 index 000000000000..31c25bd486db --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/snapshot_table.php @@ -0,0 +1,107 @@ +setName($formattedName) + ->setCluster($formattedCluster) + ->setSnapshotId($snapshotId); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->snapshotTable($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Snapshot $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 +{ + $formattedName = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + $formattedCluster = BigtableTableAdminClient::clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); + $snapshotId = '[SNAPSHOT_ID]'; + + snapshot_table_sample($formattedName, $formattedCluster, $snapshotId); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_SnapshotTable_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/test_iam_permissions.php b/Bigtable/samples/V2/BigtableTableAdminClient/test_iam_permissions.php new file mode 100644 index 000000000000..2e9c42b62f0d --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/test_iam_permissions.php @@ -0,0 +1,79 @@ +setResource($resource) + ->setPermissions($permissions); + + // Call the API and handle any network failures. + try { + /** @var TestIamPermissionsResponse $response */ + $response = $bigtableTableAdminClient->testIamPermissions($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 +{ + $resource = '[RESOURCE]'; + $permissionsElement = '[PERMISSIONS]'; + + test_iam_permissions_sample($resource, $permissionsElement); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_TestIamPermissions_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/undelete_table.php b/Bigtable/samples/V2/BigtableTableAdminClient/undelete_table.php new file mode 100644 index 000000000000..c57255e7f00e --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/undelete_table.php @@ -0,0 +1,85 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->undeleteTable($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Table $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 +{ + $formattedName = BigtableTableAdminClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); + + undelete_table_sample($formattedName); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_UndeleteTable_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/update_authorized_view.php b/Bigtable/samples/V2/BigtableTableAdminClient/update_authorized_view.php new file mode 100644 index 000000000000..bca462c4d0ae --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/update_authorized_view.php @@ -0,0 +1,71 @@ +setAuthorizedView($authorizedView); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->updateAuthorizedView($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var AuthorizedView $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()); + } +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_UpdateAuthorizedView_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/update_backup.php b/Bigtable/samples/V2/BigtableTableAdminClient/update_backup.php new file mode 100644 index 000000000000..d2aad9eaa9bf --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/update_backup.php @@ -0,0 +1,80 @@ +setSourceTable($backupSourceTable) + ->setExpireTime($backupExpireTime); + $updateMask = new FieldMask(); + $request = (new UpdateBackupRequest()) + ->setBackup($backup) + ->setUpdateMask($updateMask); + + // Call the API and handle any network failures. + try { + /** @var Backup $response */ + $response = $bigtableTableAdminClient->updateBackup($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 +{ + $backupSourceTable = '[SOURCE_TABLE]'; + + update_backup_sample($backupSourceTable); +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_UpdateBackup_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/update_schema_bundle.php b/Bigtable/samples/V2/BigtableTableAdminClient/update_schema_bundle.php new file mode 100644 index 000000000000..5e79ced2a810 --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/update_schema_bundle.php @@ -0,0 +1,71 @@ +setSchemaBundle($schemaBundle); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->updateSchemaBundle($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var SchemaBundle $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()); + } +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_UpdateSchemaBundle_sync] diff --git a/Bigtable/samples/V2/BigtableTableAdminClient/update_table.php b/Bigtable/samples/V2/BigtableTableAdminClient/update_table.php new file mode 100644 index 000000000000..c3af7971cf8c --- /dev/null +++ b/Bigtable/samples/V2/BigtableTableAdminClient/update_table.php @@ -0,0 +1,74 @@ +setTable($table) + ->setUpdateMask($updateMask); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $bigtableTableAdminClient->updateTable($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Table $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()); + } +} +// [END bigtableadmin_v2_generated_BigtableTableAdmin_UpdateTable_sync]