列出執行個體
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
列出目前專案中的執行個體。
深入探索
如需包含這個程式碼範例的詳細說明文件,請參閱下列內容:
程式碼範例
C++
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
C#
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Java
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Node.js
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
PHP
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Python
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Ruby
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 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 content provides code samples in multiple languages (C++, C#, Java, Node.js, PHP, Python, and Ruby) demonstrating how to list instances within a Google Cloud Bigtable project.\u003c/p\u003e\n"],["\u003cp\u003eThe examples show how to use the Bigtable client libraries to retrieve a list of instances and handle potential errors, such as temporary location unavailability.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication to Bigtable is achieved using Application Default Credentials, and detailed instructions for setting up are linked for local development.\u003c/p\u003e\n"],["\u003cp\u003eThere are links to the Bigtable client libraries documentation for each language and a sample browser to search and filter code samples for other Google Cloud products.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples rely on the use of the \u003ccode\u003eListInstances\u003c/code\u003e method, which can return a list of the names of the bigtable instances in the project or a message if there is any error in the process.\u003c/p\u003e\n"]]],[],null,["List the instances in the current project.\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Get instance information](/bigtable/docs/get-instance-information)\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 cbta = ::google::cloud::bigtable_admin;\n using ::google::cloud::Project;\n using ::google::cloud::StatusOr;\n [](cbta::BigtableInstanceAdminClient instance_admin,\n std::string const& project_id) {\n std::string project_name = Project(project_id).FullName();\n StatusOr\u003cgoogle::bigtable::admin::v2::ListInstancesResponse\u003e instances =\n instance_admin.ListInstances(project_name);\n if (!instances) throw std::move(instances).status();\n for (auto const& instance : instances-\u003einstances()) {\n std::cout \u003c\u003c instance.name() \u003c\u003c \"\\n\";\n }\n if (!instances-\u003efailed_locations().empty()) {\n std::cout \u003c\u003c \"The Cloud Bigtable service reports that the following \"\n \"locations are temporarily unavailable and no information \"\n \"about instances in these locations can be obtained:\\n\";\n for (auto const& failed_location : instances-\u003efailed_locations()) {\n std::cout \u003c\u003c failed_location \u003c\u003c \"\\n\";\n }\n }\n }\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 // Lists instances in the project.\n // Initialize request argument(s).\n ListInstancesRequest listInstancesRequest = new ListInstancesRequest\n {\n ParentAsProjectName = new ProjectName(projectId)\n };\n try\n {\n // Make a request.\n Console.WriteLine(\"Waiting for operation to complete...\");\n ListInstancesResponse instances = bigtableInstanceAdminClient.ListInstances(listInstancesRequest);\n }\n catch (Exception ex)\n {\n Console.WriteLine($\"Exception while requesting information about instances in {projectId} project\");\n Console.WriteLine(ex.Message);\n return -1;\n }\n Console.WriteLine(new string('-', 50));\n\nJava\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 try {\n List\u003cInstance\u003e instances = adminClient.listInstances();\n for (Instance instance : instances) {\n System.out.println(instance.getId());\n }\n } catch (PartialListInstancesException e) {\n System.err.println(\"Failed to list instances: \" + e.getMessage());\n System.err.println(\"The following zones are unavailable: \" + e.getUnavailableZones());\n System.err.println(\"But the following instances are reachable: \" + e.getInstances());\n }\n\nNode.js\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 const [instances] = await bigtable.getInstances();\n instances.forEach(instance =\u003e {\n console.log(instance.id);\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\\Cloud\\Bigtable\\Admin\\V2\\Client\\BigtableInstanceAdminClient;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\ListInstancesRequest;\n\n /**\n * List Bigtable instances in a project\n *\n * @param string $projectId The Google Cloud project ID\n */\n function list_instance(string $projectId): void\n {\n $instanceAdminClient = new BigtableInstanceAdminClient();\n\n $projectName = $instanceAdminClient-\u003eprojectName($projectId);\n\n printf('Listing Instances:' . PHP_EOL);\n $listInstancesRequest = (new ListInstancesRequest())\n -\u003esetParent($projectName);\n\n $getInstances = $instanceAdminClient-\u003elistInstances($listInstancesRequest)-\u003egetInstances();\n $instances = $getInstances-\u003egetIterator();\n\n foreach ($instances as $instance) {\n print($instance-\u003egetName() . PHP_EOL);\n }\n }\n\nPython\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 print(\"\\nListing instances:\")\n for instance_local in client.list_instances()[0]:\n print(instance_local.instance_id)\n\nRuby\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 bigtable.instances.all do |instance|\n puts \"Instance: #{instance.instance_id}\"\n end\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)."]]