AppProfile details

Retrieve AppProfile details.

Code sample

C++

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
   std::string const& profile_id) {
  StatusOr<google::bigtable::admin::v2::AppProfile> profile =
      instance_admin.GetAppProfile(instance_id, profile_id);
  if (!profile) throw std::runtime_error(profile.status().message());
  std::cout << "Application Profile details=" << profile->DebugString()
            << "\n";
}

PHP

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

use Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient;
use Google\ApiCore\ApiException;

/**
 * Get the App Profile
 *
 * @param string $projectId The Google Cloud project ID
 * @param string $instanceId The ID of the Bigtable instance
 * @param string $appProfileId The ID of the App Profile to fetch
 */
function get_app_profile(
    string $projectId,
    string $instanceId,
    string $appProfileId
): void {
    $instanceAdminClient = new BigtableInstanceAdminClient();
    $appProfileName = $instanceAdminClient->appProfileName($projectId, $instanceId, $appProfileId);

    printf('Fetching the App Profile %s' . PHP_EOL, $appProfileId);
    try {
        $appProfile = $instanceAdminClient->getAppProfile($appProfileName);
    } catch (ApiException $e) {
        if ($e->getStatus() === 'NOT_FOUND') {
            printf('App profile %s does not exist.' . PHP_EOL, $appProfileId);
            return;
        }
        throw $e;
    }

    printf('Printing Details:' . PHP_EOL);

    // Fetch some commonly used metadata
    printf('Name: %s' . PHP_EOL, $appProfile->getName());
    printf('Etag: %s' . PHP_EOL, $appProfile->getEtag());
    printf('Description: %s' . PHP_EOL, $appProfile->getDescription());
    printf('Routing Policy: %s' . PHP_EOL, $appProfile->getRoutingPolicy());

    if ($appProfile->hasSingleClusterRouting()) {
        $clusterId = $appProfile->getSingleClusterRouting()->getClusterId();
        $singleRowTransactions = $appProfile->getSingleClusterRouting()->getAllowTransactionalWrites() ? 'Yes' : 'No';
        printf('Cluster: %s' . PHP_EOL, $clusterId);
        printf('Single-Row Transactions: %s' . PHP_EOL, $singleRowTransactions);
    }
}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.