Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Cloud Endpoints Frameworks bietet API-Verwaltungsfunktionen, die mit den vom Extensible Service Proxy (ESP) für Cloud Endpoints bereitgestellten Funktionen vergleichbar sind. In Endpoints Frameworks ist ein API-Gateway eingebunden, das alle Anfragen abfängt und soweit notwendig überprüft, z. B. durch Authentifizierung, bevor sie an das API-Back-End weitergeleitet werden. Wenn das Back-End antwortet, erfasst und meldet Endpoints Frameworks telemetrische Messwerte. Sie können Messwerte für Ihre API auf der Seite Endpoints > Dienste in derGoogle Cloud console ansehen.
In Endpoints Frameworks sind unter anderem die folgenden API-Verwaltungsfunktionen verfügbar:
Damit Ihre API von Endpoints verwaltet werden kann, müssen Sie ein OpenAPI-Dokument bereitstellen, das Ihre API mit Version 2.0 der OpenAPI-Spezifikation beschreibt.
Auf dieser Seite wird beschrieben, wie Sie ein OpenAPI-Dokument generieren und bereitstellen, mit dem Endpoints Ihre API verwalten kann.
Wenn Sie keine API-Verwaltung einrichten, liefert Ihre API weiterhin Anfragen, erscheint aber nicht auf der Seite Endpoints > Dienste in derGoogle Cloud -Konsole und die von Endpoints bereitgestellten Funktionen wie Logging, Monitoring und das Festlegen von Kontingenten sind nicht verfügbar.
So fügen Sie der API Verwaltungsfunktionen hinzu:
Richten Sie Ihre Maven-Datei pom.xml oder Ihre Gradle-Datei build.gradle wie in Konfigurieren der Build-Dateien beschrieben ein.
Stellen Sie sicher, dass Sie die Google Cloud Projekt-ID in den Build-Dateien festgelegt haben.
Maven
Suchen Sie nach <endpoints.project.id> und ersetzen Sie YOUR_PROJECT_ID durch Ihre Google Cloud Projekt-ID. Beispiel:
Suchen Sie nach def projectId und ersetzen Sie YOUR_PROJECT_ID durch Ihre Google Cloud Projekt-ID. Beispiel:
def projectId = 'example-project-12345'
Achten Sie darauf, dass die Datei build.gradle die Aufgabe replaceProjectId enthält, mit der die Projekt-ID in den Dateien appengine-web.xml und web.xml festgelegt wird.
Wenn Sie die Abhängigkeiten geändert haben, bereinigen Sie Ihr Projekt und erstellen Sie dann die API:
Maven
mvnclean
mvnpackage
Gradle
gradleclean
gradlebuild
Generieren Sie das OpenAPI-Dokument:openapi.json
Maven
mvnendpoints-framework:openApiDocs
Gradle
gradleendpointsOpenApiDocs
Stellen Sie das OpenAPI-Dokument bereit:
gcloudendpointsservicesdeployopenapi.json
Bei der ersten Bereitstellung von openapi.json wird ein neuer Endpoints-Dienst mit dem Namen YOUR_PROJECT_ID.appspot.com erstellt. Bei erfolgreichem Abschluss des Vorgangs wird eine Zeile mit der Dienstkonfigurations-ID und dem Dienstnamen angezeigt, die etwa so aussieht:
Service Configuration 2017-02-13r0 uploaded for service example-project-12345.appspot.com
Im vorherigen Beispiel ist 2017-02-13r0 die Dienstkonfigurations-ID. Die Dienstkonfigurations-ID besteht aus einem Datumsstempel, gefolgt von einer Überarbeitungsnummer. Wenn Sie openapi.json noch einmal bereitstellen, wird die Revisionsnummer in der Dienstkonfigurations-ID erhöht.
Wenn Sie die Dienstkonfigurations-ID noch einmal anzeigen müssen, führen Sie den folgenden Befehl aus und ersetzen Sie dabei YOUR_PROJECT_ID durch die Projekt-ID Ihres Google Cloud -Projekts:
gcloud endpoints configs list --service=YOUR_PROJECT_ID.appspot.com
Statt ein generiertes Dokument zu verwenden, können Sie ein eigenes OpenAPI-Dokument erstellen und bereitstellen. Ersetzen Sie openapi.json aus dem obigen Beispiel einfach durch den Pfad zu Ihrem OpenAPI-Dokument. Weitere Informationen zum Erstellen eines OpenAPI-Dokuments finden Sie unter OpenAPI-Übersicht.
Bearbeiten Sie die Datei appengine-web.xml, um den Wert für eine Umgebungsvariable festzulegen:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eCloud Endpoints Frameworks provides API management features, including an API gateway that handles authentication and other checks before routing requests to the API backend, similar to the Extensible Service Proxy (ESP).\u003c/p\u003e\n"],["\u003cp\u003eEndpoints Frameworks offers API management features such as monitoring, logging, quotas, and a developer portal, all accessible through the Google Cloud console's Endpoints Services page.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize API management with Endpoints, you must deploy an OpenAPI document (version 2.0) that defines your API.\u003c/p\u003e\n"],["\u003cp\u003eAdding API management involves configuring build files (Maven or Gradle), setting the Google Cloud project ID, adding servlet filter configurations in \u003ccode\u003eweb.xml\u003c/code\u003e, and modifying dependencies and the build configuration.\u003c/p\u003e\n"],["\u003cp\u003eAfter building the API and generating the OpenAPI document, you have to deploy it and redeploy the application, to then view the API metrics in the Google Cloud console.\u003c/p\u003e\n"]]],[],null,["# Adding API management\n\nCloud Endpoints Frameworks provides API management features that are comparable to\nthe features that the\n[Extensible Service Proxy (ESP)](/endpoints/docs/frameworks/glossary#extensible_service_proxy)\nprovides for Cloud Endpoints. Endpoints Frameworks includes a\nbuilt-in\n[API gateway](https://en.wikipedia.org/wiki/API_management)\nthat intercepts all requests and performs any necessary checks, such as\nauthentication, before forwarding the request to the API backend. When the backend\nresponds, Endpoints Frameworks gathers and reports telemetry. You can\nview metrics for your API on the **Endpoints** \\\u003e **Services** page in the\nGoogle Cloud console.\n\nThe API management features available in Endpoints Frameworks include:\n\n- [Monitoring](/endpoints/docs/frameworks/monitoring-your-api)\n- [Logging](/endpoints/docs/frameworks/monitoring-your-api#logs)\n- [Quotas](/endpoints/docs/openapi/quotas-overview)\n- [Developer portal](/endpoints/docs/openapi/dev-portal-overview)\n\nFor your API to be managed by Endpoints, you must deploy\nan OpenAPI document that describes your API using version 2.0 of the\n[OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md).\nThis page describes how to generate and deploy an OpenAPI document that\nenables Endpoints to manage your API.\n\nIf you don't add API management, your API still serves requests, but your\nAPI doesn't appear on the **Endpoints** \\\u003e **Services** page in the\nGoogle Cloud console, and the functionality provided by\nEndpoints, such as logging, monitoring, and setting quotas, isn't\navailable.\n\nTo add API management to your API:\n\n1. Set up your Maven `pom.xml` file or your Gradle `build.gradle` file as\n described in\n [Configuring the build files](/endpoints/docs/frameworks/java/set-up-environment#configuring_the_build_files).\n\n2. Make sure that you set the Google Cloud project ID in the\n build files.\n\n ### Maven\n\n Search for `\u003cendpoints.project.id\u003e`, and replace\n \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e with your\n Google Cloud project ID. For example:\n\n `\u003cendpoints.project.id\u003eexample-project-12345\u003c/endpoints.project.id\u003e`\n\n\n \u003cendpoints.project.id\u003eYOUR_PROJECT_ID\u003c/endpoints.project.id\u003e\n\n \u003cbr /\u003e\n\n ### Gradle\n\n 1. Search for `def projectId`, and replace \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e with your Google Cloud project ID. For example:\n\n `def projectId = 'example-project-12345'`\n 2. Make sure your `build.gradle` file contains the `replaceProjectId` task, which sets the project ID in the `appengine-web.xml` and `web.xml` files.\n\n\n task replaceProjectId(type: Copy) {\n from 'src/main/webapp/WEB-INF/'\n include '*.xml'\n into \"build/exploded-${archivesBaseName}/WEB-INF\"\n expand(endpoints:[project:[id:projectId]])\n filteringCharset = 'UTF-8'\n }\n\n \u003cbr /\u003e\n\n3. In your API project's `web.xml` file, add the API management servlet filter\n configuration:\n\n \u003c!-- Add a filter that fetches the service config from service management. --\u003e\n \u003cfilter\u003e\n \u003cfilter-name\u003eendpoints-api-configuration\u003c/filter-name\u003e\n \u003cfilter-class\u003ecom.google.api.control.ServiceManagementConfigFilter\u003c/filter-class\u003e\n \u003c/filter\u003e\n\n \u003c!-- Add a filter that performs Endpoints logging and monitoring. --\u003e\n \u003cfilter\u003e\n \u003cfilter-name\u003eendpoints-api-controller\u003c/filter-name\u003e\n \u003cfilter-class\u003ecom.google.api.control.extensions.appengine.GoogleAppEngineControlFilter\u003c/filter-class\u003e\n \u003cinit-param\u003e\n \u003cparam-name\u003eendpoints.projectId\u003c/param-name\u003e\n \u003cparam-value\u003e${endpoints.project.id}\u003c/param-value\u003e\n \u003c/init-param\u003e\n \u003cinit-param\u003e\n \u003cparam-name\u003eendpoints.serviceName\u003c/param-name\u003e\n \u003cparam-value\u003e${endpoints.project.id}.appspot.com\u003c/param-value\u003e\n \u003c/init-param\u003e\n \u003c/filter\u003e\n\n \u003cfilter-mapping\u003e\n \u003cfilter-name\u003eendpoints-api-configuration\u003c/filter-name\u003e\n \u003cservlet-name\u003eEndpointsServlet\u003c/servlet-name\u003e\n \u003c/filter-mapping\u003e\n\n \u003cfilter-mapping\u003e\n \u003cfilter-name\u003eendpoints-api-controller\u003c/filter-name\u003e\n \u003cservlet-name\u003eEndpointsServlet\u003c/servlet-name\u003e\n \u003c/filter-mapping\u003e\n\n4. Modify your API project's build configuration:\n\n ### Maven\n\n 1. Add the API management dependencies:\n\n \u003cdependency\u003e\n \u003cgroupId\u003ecom.google.endpoints\u003c/groupId\u003e\n \u003cartifactId\u003eendpoints-management-control-appengine-all\u003c/artifactId\u003e\n \u003cversion\u003e1.0.14\u003c/version\u003e\n \u003c/dependency\u003e\n\n 2. Include the plugin that you can use to generate client libraries\n and the OpenAPI document, `openapi.json`:\n\n \u003cplugin\u003e\n \u003cgroupId\u003ecom.google.cloud.tools\u003c/groupId\u003e\n \u003cartifactId\u003eendpoints-framework-maven-plugin\u003c/artifactId\u003e\n \u003cversion\u003e2.1.0\u003c/version\u003e\n \u003cconfiguration\u003e\n \u003c!-- plugin configuration --\u003e\n \u003chostname\u003e${endpoints.project.id}.appspot.com\u003c/hostname\u003e\n \u003c/configuration\u003e\n \u003c/plugin\u003e\n\n ### Gradle\n\n 1. Add the API management dependencies:\n\n compile 'com.google.endpoints:endpoints-management-control-appengine:1.0.14'\n compile 'com.google.endpoints:endpoints-framework-auth:1.0.14'\n\n 2. Declare the external dependency so that the plugin is\n retrieved from Maven Central:\n\n classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:2.1.0'\n\n 3. Use the server-side Endpoints Frameworks Gradle plugin,\n which generates the OpenAPI document:\n\n apply plugin: 'com.google.cloud.tools.endpoints-framework-server'\n\n 4. Configure the name of your Endpoints service:\n\n endpointsServer {\n // Endpoints Framework Plugin server-side configuration\n hostname = \"${projectId}.appspot.com\"\n }\n\n5. After modifying dependencies, clean your project and then build your API:\n\n ### Maven\n\n ```bash\n mvn clean\n mvn package\n ```\n\n ### Gradle\n\n ```bash\n gradle clean\n gradle build\n ```\n6. Generate the OpenAPI document, `openapi.json`:\n\n ### Maven\n\n ```bash\n mvn endpoints-framework:openApiDocs\n ```\n\n ### Gradle\n\n ```bash\n gradle endpointsOpenApiDocs\n ```\n7. Deploy the OpenAPI document:\n\n gcloud endpoints services deploy openapi.json\n\n The first time you deploy `openapi.json`, a new Endpoints\n service is created with the name\n \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e`.appspot.com`. On\n successful completion, a line similar to the following displays\n the service configuration ID and the service name:\n\n \u003cbr /\u003e\n\n ```\n Service Configuration 2017-02-13r0 uploaded for service example-project-12345.appspot.com\n ```\n\n In the preceding example, `2017-02-13r0` is the service configuration\n ID. The service configuration ID consists of a date stamp followed by a\n revision number. If you deploy `openapi.json` again, the revision number is\n incremented in the service configuration ID.\n\n If you need to display the service configuration ID again, run the following\n command, but replace \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e with the\n project ID of your Google Cloud project: \n\n ```\n gcloud endpoints configs list --service=YOUR_PROJECT_ID.appspot.com\n ```\n\n You can create your own OpenAPI document and deploy it, rather than\n using a generated one. Simply replace `openapi.json` above with the path to\n your OpenAPI document. For more information on writing an OpenAPI document,\n see\n [OpenAPI overview](/endpoints/docs/openapi/openapi-overview).\n8. Edit your `appengine-web.xml` file to set the value for an environment\n variable:\n\n \u003cenv-variables\u003e\n \u003cenv-var name=\"ENDPOINTS_SERVICE_NAME\" value=\"${endpoints.project.id}.appspot.com\" /\u003e\n \u003c/env-variables\u003e\n\n Replace `${endpoints.project.id}` with your Google Cloud project ID.\n For example: \n\n \u003cenv-var name=\"ENDPOINTS_SERVICE_NAME\" value=\"example-project-12345.appspot.com\" /\u003e\n\n9. Redeploy your application.\n\n \u003cbr /\u003e\n\n ### Maven\n\n ```java\n mvn appengine:deploy\n ```\n\n ### Gradle\n\n ```java\n gradle appengineDeploy\n ```\n\n \u003cbr /\u003e\n\n10. Test your API by making some requests to it.\n\n11. To\n [view your API metrics](/endpoints/docs/frameworks/monitoring-your-api),\n open the **Endpoints** \\\u003e **Services** page in the Google Cloud console for your project: \n\n\n [Go to the Endpoints Services page](https://console.cloud.google.com/endpoints)\n\n \u003cbr /\u003e"]]