Mencantumkan instance
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Mencantumkan instance dalam project saat ini.
Mempelajari lebih lanjut
Untuk dokumentasi mendetail yang menyertakan contoh kode ini, lihat artikel berikut:
Contoh kode
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","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)."]]