Details zu App-Profil

AppProfil-Details abrufen.

Codebeispiel

C++

Informationen zum Installieren und Verwenden der Clientbibliothek für Bigtable finden Sie unter Bigtable-Clientbibliotheken.

Richten Sie Standardanmeldedaten für Anwendungen ein, um sich bei Bigtable zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

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

Informationen zum Installieren und Verwenden der Clientbibliothek für Bigtable finden Sie unter Bigtable-Clientbibliotheken.

Richten Sie Standardanmeldedaten für Anwendungen ein, um sich bei Bigtable zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

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);
    }
}

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.