Create a new Datastore admin client
Stay organized with collections
Save and categorize content based on your preferences.
Create a new Datastore admin client.
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis content demonstrates how to create a new Datastore admin client using code samples in C#, Go, Python, and Ruby.\u003c/p\u003e\n"],["\u003cp\u003eEach language section directs users to the Datastore mode client libraries for installation and usage instructions.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication for Datastore mode requires setting up Application Default Credentials, with a link provided for setting it up in a local development environment.\u003c/p\u003e\n"],["\u003cp\u003eLinks to the respective API reference documentation for each language are included for further information.\u003c/p\u003e\n"],["\u003cp\u003eThe content provides resources for finding other code samples for different Google Cloud Products via the Google Cloud sample browser.\u003c/p\u003e\n"]]],[],null,["# Create a new Datastore admin client.\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 // Create client\n DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.Create();\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 )\n\n // clientCreate creates a new Datastore admin client.\n func clientCreate(w io.Writer) (*admin.DatastoreAdminClient, error) {\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 \t// Close client when done using it.\n \t// defer client.Close()\n \tfmt.Fprintf(w, \"Admin client created\\n\")\n \treturn client, nil\n }\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 from google.cloud.datastore_admin_v1 import https://cloud.google.com/python/docs/reference/datastore/latest/google.cloud.datastore_admin_v1.services.datastore_admin.client.DatastoreAdminClient.html\n\n\n def client_create():\n \"\"\"Creates a new Datastore admin client.\"\"\"\n client = DatastoreAdminClient()\n\n print(\"Admin client created\\n\")\n return client\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 # Import the client library\n require \"google/cloud/datastore/admin/v1\"\n\n # Instantiate a client\n client = Google::Cloud::Datastore::Admin::V1::DatastoreAdmin::Client.new\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)."]]