Obtenir les détails du cluster
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Obtenir les détails du cluster selon l'ID d'instance dans le projet actuel.
Exemple de code
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","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)."]]