This blog walks you through deploying a sample API with Google Cloud Endpoints. The sample code includes:
- A REST API that you can query to find the name of an airport from its three-letter IATA code.
- A script that uploads the API configuration to Cloud Endpoints.
- A script that deploys a application to Google App Engine to host the sample API.
After you send some requests to the sample API, you can view the Cloud Endpoints Activity Graphs and Logs, tools that allow you to monitor your APIs and gain insights into their usage.
To go ahead with the endpoints we need an application that will be deployed onto the app engine, You can download the specific application and the configuration file from below given git URL.
Execute below commands on the cloud shell.
gcloud projects list
List’s the projects and it’s information.
gcloud config set project [YOUR-PROJECT-ID]
Set which project you want to use for further configuration.
Getting the sample code
Clone the repository with configuration files and application
Checkout to the specific directory
Deploying the Endpoints configuration
The script then deploys the OpenAPI configuration to Service Management using the command: gcloud endpoints services deploy openapi.yaml
Above snapshot shows the details of the endpoint deployed onto the google cloud, it shows all requests obtained to the endpoint for every time interval.
Above snapshot shows the details about the endpoint like
· Errors in endpoint access
· Latency of endpoint retrieval
· Methods called
· No of request (Passes or Failed)
Deploying the API back-end
The script runs the following command to create an App Engine flexible environment gcloud app create — region=”$REGION”
Above snapshot depict the summary graph of application deployed which will act as a back-end for the endpoint, it will show all request count on the application.
Sending requests to the Endpoint
The script echoes the
curl command that it uses to send a request to the API, and then displays the result. You'll see something like the following on the console
Above snapshot depict the methods called and number of requests made to the app deployed onto app engine.