Getting Started with Endpoints on App Engine Flexible Environment

This tutorial shows you how to configure, deploy, and send requests to a
sample API running on an instance in the
App Engine flexible environment. The sample
code's REST API is described using the OpenAPI Specification.
The tutorial also shows you how to create an API key
and use it in the request to the API.

Make sure that Cloud SDK (gcloud) is authorized to access your data and services on Google Cloud Platform:

gcloud auth login

A new browser tab opens and you are prompted to choose an account.

Set the default project to your project ID.

gcloud config set project [YOUR-PROJECT-ID]

Replace [YOUR-PROJECT-ID] with your project ID. Do not include the square brackets.
If you
have other Cloud Platform projects, and you want to use gcloud to manage them, see
Managing Cloud SDK Configurations.

On the line with the host field, replace
YOUR-PROJECT-ID with your Cloud project ID. For example:

host: "example-project.appspot.com"

Cloud Endpoints uses the text configured in the host field as
the service name. When you deploy the API to the App Engine backend, a DNS entry
with a name in the format "YOUR-PROJECT-ID.appspot.com"
is created automatically.

Note: The configuration sample above displays lines
near the host field, which you need to modify. To run
Cloud Endpoints, the complete configuration file is required.

Deploying the Endpoints configuration

To deploy the Endpoints configuration, you use Google Service Management,
an infrastructure service of Google Cloud Platform that manages other APIs
and services, including services created using Cloud Endpoints.

To deploy the Endpoints configuration:

Make sure you are in the endpoints/getting-started directory.

Invoke the following command:

gcloud service-management deploy openapi-appengine.yaml

This creates a new Cloud Endpoints service with the name that you specified
in the host field of the openapi-appengine.yaml file (if it does
not already exist). The service is updated according to your OpenAPI
configuration file. No matter what the Endpoints service name is, when you deploy
the API on App Engine, a DNS record is created using the name
format PROJECT-ID.appspot.com, which is the FQDN that you use when
you send requests to the API.

As it is creating and configuring the service, Service Management outputs a
great deal of information to the terminal. You can safely ignore the warnings
about the paths in openapi-appengine.yaml not requiring an API key. On successful
completion, you will see a line like the following that displays the service
configuration ID and the service name:

Service Configuration [2017-02-13-r2] uploaded for service [example-project.appspot.com]

Deploying the API backend

So far you have deployed the OpenAPI configuration to Service Management,
but you have not yet deployed the code that will serve the API backend. This
section walks you through deploying the sample API to App Engine.

In the sample code directory, open app.yaml. (If you are using
the Java version of the sample, the location of app.yaml is:
java-docs-samples/endpoints/getting-started/src/main/appengine)

In the following section:

endpoints_api_service:
# The following values are to be replaced by information from the output of
# 'gcloud service-management deploy openapi-appengine.yaml' command.
name: ENDPOINTS-SERVICE-NAME
config_id: ENDPOINTS-CONFIG-ID

Replace ENDPOINTS-SERVICE-NAME with your Endpoints service
name.

Replace ENDPOINTS-CONFIG-ID with the service configuration ID displayed in
the first step. For example: