Kurzanleitung: Clientbibliotheken verwenden
Auf dieser Seite werden die ersten Schritte mit der Food Ordering AI Agent API in Ihrer bevorzugten Programmiersprache beschrieben.
Hinweis
- Melden Sie sich in Ihrem Google Cloud Konto an. Wenn Sie noch kein Konto haben Google Cloud, erstellen Sie ein Konto, um die Leistung unserer Produkte in der Praxis sehen und bewerten zu können. Neukunden erhalten außerdem ein Guthaben von 300 $, um Arbeitslasten auszuführen, zu testen und bereitzustellen.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Food Ordering AI Agent API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
Create a service account:
-
Ensure that you have the Create Service Accounts IAM role
(
roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
Ensure that you have the Create Service Accounts IAM role
(
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALSto the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Food Ordering AI Agent API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
Create a service account:
-
Ensure that you have the Create Service Accounts IAM role
(
roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
Ensure that you have the Create Service Accounts IAM role
(
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALSto the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.
Clientbibliothek installieren
C#
Weitere Informationen zur Einrichtung der C#-Entwicklungsumgebung finden Sie im Einrichtungsleitfaden für die C#-Entwicklungsumgebung.
Install-Package Google.Cloud.PubSub.V1 -Pre
Go
go get cloud.google.com/go/pubsub
Java
Weitere Informationen zur Einrichtung der Java-Entwicklungsumgebung finden Sie im Einrichtungsleitfaden für die Java-Entwicklungsumgebung.
Wenn Sie Maven verwenden, fügen Sie Ihrer Datei pom.xml den folgenden Code hinzu. Weitere Informationen zu
BOMs finden Sie unter The Google Cloud Platform Libraries BOM.
Wenn Sie Gradle verwenden, fügen Sie den Abhängigkeiten Folgendes hinzu:
Wenn Sie sbt nutzen, fügen Sie den Abhängigkeiten Folgendes hinzu:
Wenn Sie Visual Studio Code oder IntelliJ verwenden, können Sie Ihrem Projekt mithilfe der folgenden IDE-Plug-ins Clientbibliotheken hinzufügen:
Diese Plug-ins bieten zusätzliche Funktionen wie die Schlüsselverwaltung für Dienstkonten. Einzelheiten finden Sie in der Dokumentation der einzelnen Plug-ins.
Node.js
Weitere Informationen zur Einrichtung der Node.js-Entwicklungsumgebung finden Sie im Einrichtungsleitfaden für die Node.js-Entwicklungsumgebung.
npm install @google-cloud/pubsub
PHP
composer require google/cloud-pubsub
Python
Weitere Informationen zur Einrichtung der Python-Entwicklungsumgebung finden Sie im Einrichtungsleitfaden für die Python-Entwicklungsumgebung.
pip install --upgrade google-cloud-pubsub
Ruby
Weitere Informationen zur Einrichtung der Ruby-Entwicklungsumgebung finden Sie im Einrichtungshandbuch für die Ruby-Entwicklungsumgebung.
gem install google-cloud-pubsub
Aktion ausführen
Jetzt können Sie Food Ordering AI Agent verwenden, um eine Aktion auszuführen. Führen Sie den folgenden Code aus, um Ihre erste Aktion auszuführen:
C#
Richten Sie zur Authentifizierung bei Food Ordering AI Agent Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.
Go
Richten Sie zur Authentifizierung bei Food Ordering AI Agent Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.
Java
Richten Sie zur Authentifizierung bei Food Ordering AI Agent Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.
Node.js
Richten Sie zur Authentifizierung bei Food Ordering AI Agent Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.
PHP
Richten Sie zur Authentifizierung bei Food Ordering AI Agent Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.
Python
Richten Sie zur Authentifizierung bei Food Ordering AI Agent Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.
Ruby
Richten Sie zur Authentifizierung bei Food Ordering AI Agent Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.
Wie ist es gelaufen?
Bereinigen
So vermeiden Sie, dass Ihrem Google-Konto die in dieser Kurzanleitung verwendeten Ressourcen in Rechnung gestellt werden:
- Löschen Sie das Projekt mit Google Cloud console , wenn Sie es nicht benötigen.
Nächste Schritte
Weitere Informationen zu den Food Ordering AI Agent API-Clientbibliotheken