Mendapatkan indeks admin
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Mendapatkan indeks admin
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 C#, Go, Node.js, Python, and Ruby for retrieving an index in Datastore mode.\u003c/p\u003e\n"],["\u003cp\u003eThe examples demonstrate how to use the Datastore Admin client libraries to fetch index information, including project ID and index ID.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication to Datastore mode requires setting up Application Default Credentials (ADC), and instructions for local development setup are linked.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code samples can be found within the documentation of Datastore client libraries for each of the listed programming languages.\u003c/p\u003e\n"],["\u003cp\u003eYou can further explore examples and operations for other google cloud products in the Google Cloud sample browser.\u003c/p\u003e\n"]]],[],null,["# Get admin index\n\nCode sample\n-----------\n\n### C#\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode C# API\nreference documentation](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest).\n\n\nTo authenticate to Datastore mode, 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\n using https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.html;\n using System;\n using Index = Google.Cloud.Datastore.Admin.V1.Index;\n\n public class GetIndexSample\n {\n public Index GetIndex(\n string projectId = \"your-project-id\",\n string indexId = \"your-index-id\")\n {\n // Create client\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.DatastoreAdminClient.html datastoreAdminClient = https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.DatastoreAdminClient.html.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.DatastoreAdminClient.html#Google_Cloud_Datastore_Admin_V1_DatastoreAdminClient_Create();\n\n // Initialize request argument(s)\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.GetIndexRequest.html getIndexRequest = new https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.GetIndexRequest.html\n {\n ProjectId = projectId,\n IndexId = indexId\n };\n\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.Index.html index = datastoreAdminClient.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.DatastoreAdminClient.html#Google_Cloud_Datastore_Admin_V1_DatastoreAdminClient_GetIndex_Google_Cloud_Datastore_Admin_V1_GetIndexRequest_Google_Api_Gax_Grpc_CallSettings_(getIndexRequest);\n\n Console.WriteLine($\"Index Id: {index.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.Index.html#Google_Cloud_Datastore_Admin_V1_Index_IndexId}\");\n Console.WriteLine($\"Kind: {index.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.Index.html#Google_Cloud_Datastore_Admin_V1_Index_Kind}\");\n Console.WriteLine(\"Properties:\");\n foreach (var property in index.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.Index.html#Google_Cloud_Datastore_Admin_V1_Index_Properties)\n {\n Console.WriteLine($\"Property: {property.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.Admin.V1/latest/Google.Cloud.Datastore.Admin.V1.Index.Types.IndexedProperty.html#Google_Cloud_Datastore_Admin_V1_Index_Types_IndexedProperty_Name}\");\n Console.WriteLine($\"Direction: {property.Direction}\");\n }\n return index;\n }\n }\n\n### Go\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode Go API\nreference documentation](https://cloud.google.com/go/docs/reference/cloud.google.com/go/datastore/latest).\n\n\nTo authenticate to Datastore mode, 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 import (\n \t\"context\"\n \t\"fmt\"\n \t\"io\"\n\n \tadmin \"cloud.google.com/go/datastore/admin/apiv1\"\n \t\"cloud.google.com/go/datastore/admin/apiv1/adminpb\"\n )\n\n // indexGet gets an index.\n func indexGet(w io.Writer, projectID, indexID string) (*adminpb.Index, error) {\n \t// projectID := \"my-project-id\"\n \t// indexID := \"my-index\"\n \tctx := context.Background()\n \tclient, err := admin.NewDatastoreAdminClient(ctx)\n \tif err != nil {\n \t\treturn nil, fmt.Errorf(\"admin.NewDatastoreAdminClient: %w\", err)\n \t}\n \tdefer client.https://cloud.google.com/go/docs/reference/cloud.google.com/go/datastore/latest/admin/apiv1.html#cloud_google_com_go_datastore_admin_apiv1_DatastoreAdminClient_Close()\n\n \treq := &adminpb.GetIndexRequest{\n \t\tProjectId: projectID,\n \t\tIndexId: indexID,\n \t}\n \tindex, err := client.GetIndex(ctx, req)\n \tif err != nil {\n \t\treturn nil, fmt.Errorf(\"client.GetIndex: %w\", err)\n \t}\n\n \tfmt.Fprintf(w, \"Got index: %v\\n\", index.IndexId)\n \treturn index, nil\n }\n\n### Node.js\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode Node.js API\nreference documentation](https://cloud.google.com/nodejs/docs/reference/datastore/latest).\n\n\nTo authenticate to Datastore mode, 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 {Datastore} = require('https://cloud.google.com/nodejs/docs/reference/datastore/latest/overview.html');\n const datastore = new https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/datastore.html();\n\n async function getIndex() {\n /**\n * TODO(developer): Uncomment these variables before running the sample.\n */\n // const indexId = 'YOUR_INDEX_ID';\n\n // Create a reference to the index before performing operations on it.\n const index = datastore.https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/datastore.html(indexId);\n\n // Get the index's metadata, including its state, properties, and more.\n const [metadata] = await https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/datastore.html.https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/index.html();\n console.log('Properties:', https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/index.html.properties);\n }\n\n getIndex();\n\n### Python\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode Python API\nreference documentation](https://cloud.google.com/python/docs/reference/datastore/latest).\n\n\nTo authenticate to Datastore mode, 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 def get_index(project_id, index_id):\n \"\"\"Gets an index.\"\"\"\n # project_id := \"my-project-id\"\n # index_id := \"my-index\"\n client = DatastoreAdminClient()\n index = client.get_index({\"project_id\": project_id, \"index_id\": index_id})\n\n print(\"Got index: %v\\n\", index.index_id)\n return index\n\n### Ruby\n\n\nTo learn how to install and use the client library for Datastore mode, see\n[Datastore mode client libraries](/datastore/docs/reference/libraries).\n\n\nFor more information, see the\n[Datastore mode Ruby API\nreference documentation](/ruby/docs/reference/google-cloud-datastore/latest).\n\n\nTo authenticate to Datastore mode, 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 # project_id = \"project-id\"\n # index_id = \"my-index\"\n index = client.get_index project_id: project_id, index_id: index_id\n puts \"Got index: #{index.index_id}\"\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=datastore)."]]