Dettagli di AppProfile

Recupera i dettagli AppProfile.

Esempio di codice

C++

Per scoprire come installare e utilizzare la libreria client per Bigtable, consulta Librerie client di Bigtable.

Per eseguire l'autenticazione in Bigtable, configura Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

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

PHP

Per scoprire come installare e utilizzare la libreria client per Bigtable, consulta Librerie client di Bigtable.

Per eseguire l'autenticazione in Bigtable, configura Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

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

/**
 * 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 {
        $getAppProfileRequest = (new GetAppProfileRequest())
            ->setName($appProfileName);
        $appProfile = $instanceAdminClient->getAppProfile($getAppProfileRequest);
    } 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);
    }
}

Passaggi successivi

Per cercare e filtrare esempi di codice per altri prodotti Google Cloud, consulta il browser di esempio Google Cloud.