クラスタの詳細取得
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
現在のプロジェクトのインスタンス ID に基づいてクラスタの詳細を取得します。
コードサンプル
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page provides code samples in C++ and PHP to retrieve cluster details using the Bigtable client library within the current project.\u003c/p\u003e\n"],["\u003cp\u003eThe code demonstrates how to use the \u003ccode\u003eGetCluster\u003c/code\u003e method to fetch specific information about a cluster, given the project ID, instance ID, and cluster ID.\u003c/p\u003e\n"],["\u003cp\u003eThe PHP example shows how to handle potential errors, such as a \u003ccode\u003eNOT_FOUND\u003c/code\u003e status, and prints essential cluster metadata like name, location, state, storage type, nodes, and encryption configuration.\u003c/p\u003e\n"],["\u003cp\u003eThe page provides links to the Bigtable client libraries and guides on setting up Application Default Credentials for authentication.\u003c/p\u003e\n"],["\u003cp\u003eThe page shows the user how to search and filter code samples for other google cloud products using the sample browser.\u003c/p\u003e\n"]]],[],null,["Get cluster details given the instance ID in the current project.\n\nCode sample \n\nC++\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n namespace cbt = ::google::cloud::bigtable;\n namespace cbta = ::google::cloud::bigtable_admin;\n using ::google::cloud::StatusOr;\n [](cbta::BigtableInstanceAdminClient instance_admin,\n std::string const& project_id, std::string const& instance_id,\n std::string const& cluster_id) {\n std::string cluster_name =\n cbt::ClusterName(project_id, instance_id, cluster_id);\n StatusOr\u003cgoogle::bigtable::admin::v2::Cluster\u003e cluster =\n instance_admin.GetCluster(cluster_name);\n if (!cluster) throw std::move(cluster).status();\n std::cout \u003c\u003c \"GetCluster details : \" \u003c\u003c cluster-\u003eDebugString() \u003c\u003c \"\\n\";\n }\n\nPHP\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n use Google\\ApiCore\\ApiException;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\Client\\BigtableInstanceAdminClient;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\GetClusterRequest;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\Instance\\State;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\StorageType;\n\n /**\n * Get a Bigtable cluster\n *\n * @param string $projectId The Google Cloud project ID\n * @param string $instanceId The ID of the Bigtable instance\n * @param string $clusterId The ID of the cluster to fetch\n */\n function get_cluster(\n string $projectId,\n string $instanceId,\n string $clusterId\n ): void {\n $instanceAdminClient = new BigtableInstanceAdminClient();\n\n printf('Fetching the Cluster %s' . PHP_EOL, $clusterId);\n try {\n $clusterName = $instanceAdminClient-\u003eclusterName($projectId, $instanceId, $clusterId);\n $getClusterRequest = (new GetClusterRequest())\n -\u003esetName($clusterName);\n $cluster = $instanceAdminClient-\u003egetCluster($getClusterRequest);\n } catch (ApiException $e) {\n if ($e-\u003egetStatus() === 'NOT_FOUND') {\n printf('Cluster %s does not exists.' . PHP_EOL, $clusterId);\n return;\n }\n throw $e;\n }\n\n printf('Printing Details:' . PHP_EOL);\n\n // Fetch some commonly used metadata\n printf('Name: ' . $cluster-\u003egetName() . PHP_EOL);\n printf('Location: ' . $cluster-\u003egetLocation() . PHP_EOL);\n printf('State: ' . State::name($cluster-\u003egetState()) . PHP_EOL);\n printf('Default Storage Type: ' . StorageType::name($cluster-\u003egetDefaultStorageType()) . PHP_EOL);\n printf('Nodes: ' . $cluster-\u003egetServeNodes() . PHP_EOL);\n printf('Encryption Config: ' . ($cluster-\u003ehasEncryptionConfig() ? $cluster-\u003egetEncryptionConfig()-\u003egetKmsKeyName() : 'N/A') . PHP_EOL);\n }\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=bigtable)."]]