Créer un client administrateur Datastore
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Créez un client administrateur Datastore.
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 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)."]]