SlideShare a Scribd company logo
Build Android App using GCE
& GAE
By Love Sharma
Hello World
Some introductions are in order
● If you have question, raise a hand.
● There will be dedicated Q&A time at the end of the lecture
● All source code will be provided in the form of Github link.
Topics Today
● What is Google App engine?
● What are RESTful APIs?
● What is Google Cloud Endpoints?
● Testing API Locally / Google API Explorer
● Generate client libraries for Android / iOS
● Consuming endpoints in your android application
● Walkthrough sample tic-tac-toe project.
● Q&A
Google App Engine
● Platform as a Service (PaaS)
● Easy to build and maintain.
● Easy to scale as the traffic and storage needs grow.
● Supported programming languages
○ Java
○ Python
○ PHP
○ Go
● Datastore
● Easily integrated with Google Cloud SQL
When to use GAE?
● You don’t want to get troubled for setting up a server.
● You want instant for-free nearly infinite scalability support.
● You don’t feel like taking care of your own server monitoring tools.
● You need pricing that fits your actual usage and isn't time-slot based (App
engine provides pay-per-drink cost model).
● You are able to chunk long tasks into 60 second pieces.
● You are able to work without direct access to local file system.
RESTful APIs (quick recap)
● A web service, which uses HTTP as a transport.
● Central idea: there are resources which we want to export
● Resources are sent back and forth using their representation.
● REST = representational state transfer.
● Four main operations, mapped to HTTP method:
○ GET - read or list the data
○ POST - add new data
○ PUT - update existing data
○ DELETE - as follows from the name
What is Google Cloud Endpoints?
● Easily create API backend.
● Simply Annotate your code.
● Automatically generate client libraries.
● Leverage App engine on Mobile.
● Authenticate end users.
○ OAuth 2.0 Support
What is Google Cloud Endpoints?
Let’s see some `code`
Import messages libraries need to create
a backend API.
Then, the message classes are
defined. These messages are used to
define the requests and responses for
the API
Next, the sample defines the
API service. The API service
defines and implements the
methods that are available for
the API
Let’s see some `code`
This API has one methods:
● The board_get_movemethod return with a
single ‘O’ added to the board passed
in.
Finally, the sample defines the API server
which is responsible for routing requests to
an individual service.
APP = endpoints.api_server([TicTacToeApi])
Running and testing your backend API
In the project directory, start the development server:
~/path/to/python/sdk/google_appengine/dev_appserver.py .
When the backend is running successfully, a message similar to this one is
displayed:
INFO 2013-10-07 19:41:16,687 admin_server.py:117] Starting admin server at: http://localhost:
8000
In your browser, visit this URL:
http://localhost:8080/_ah/api/explorer
API Explorer
A. Click tictactoe to display the available methods.
B. Click tictactoe.board.getmove to display the
Explorer form for it.
C. Select state from Request body and enter current
state of tic-tac-toe board e.g., “X--------”
D. Execute in order to get next “O” move.
E. Notice the display of the request and response. In the
Response, you'll see the OK result and the returned
message, “XO-------”.
Generate Client Libraries
Invoke the Endpoints command line tool as follows:
google_appengine/endpointscfg.py get_client_lib java -bs desired_client_bundle your_module.
YourServiceClass
Using a more concrete example to generate the client library:
google_appengine/endpointscfg.py get_client_lib java -bs gradle tictactoe_api.TicTacToeApi
When successful, the tool displays a message similar to:
API client library written to ./tictactoe-v1.zip
Consuming endpoints in your android app
To add the client library to the Android project:
● Add a /libs directory to your project if it doesn't already have one. It should
be a peer to the /src directory.
● Copy the client library generated from the backend API into /libs.
● Select the library you just added, right-click, then select Add As Library to
your project.
Let’s integrate...
Creating the service object
In your project code, you must use a service
object to make requests to the backend API.
For unauthenticated requests, construct the
service object as follows:
Calling the backend API
In your project, call the API using the service
object.
In the snippet, we are requesting a list of all
Score objects on the server. If list required
parameters, or a request body, you would
provide them in the invocation. Android Studio
provides code completion to identity available
method calls, and their required parameters.
Let’s integrate...
Note: It is important to note that because
API calls result in requests over the
network, you are required to make
requests in their own thread. (This
requirement was added to recent versions
of Android, but it is a best practice even in
older versions.)
To do this, you use a Thread or
AsyncTask. For example:
Q & A
References
● https://cloud.google.com/endpoints/
● https://cloud.google.com/appengine/docs/python/endpoints/
● https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-
python
● https://console.developers.google.com
● https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-
android

More Related Content

What's hot

GraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL: The Missing Link Between Frontend and Backend DevsGraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL: The Missing Link Between Frontend and Backend Devs
Sashko Stubailo
 
GraphQL
GraphQLGraphQL
GraphQL
Joel Corrêa
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
Sashko Stubailo
 
Angular Ivy- An Overview
Angular Ivy- An OverviewAngular Ivy- An Overview
Angular Ivy- An Overview
Jalpesh Vadgama
 
Google Cloud Enpoints
Google Cloud EnpointsGoogle Cloud Enpoints
Google Cloud Enpoints
Mattia Gasperotti
 
Graphql
GraphqlGraphql
Case Study: Integration Automation Create Delightful API Docs
Case Study: Integration Automation Create Delightful API DocsCase Study: Integration Automation Create Delightful API Docs
Case Study: Integration Automation Create Delightful API Docs
Pronovix
 
IVY: an overview
IVY: an overviewIVY: an overview
IVY: an overview
RobertoMontes31
 
Into to GraphQL
Into to GraphQLInto to GraphQL
Into to GraphQL
shobot
 
apidays LIVE Australia 2020 - Productising your Microservices as API Products...
apidays LIVE Australia 2020 - Productising your Microservices as API Products...apidays LIVE Australia 2020 - Productising your Microservices as API Products...
apidays LIVE Australia 2020 - Productising your Microservices as API Products...
apidays
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting started
TejinderMakkar
 
Taking Control of your Data with GraphQL
Taking Control of your Data with GraphQLTaking Control of your Data with GraphQL
Taking Control of your Data with GraphQL
Vinci Rufus
 
Tools for designing and building great APIs
Tools for designing and building great APIsTools for designing and building great APIs
Tools for designing and building great APIs
Kong Inc.
 
GraphQL
GraphQLGraphQL
MuleSoft Surat Live Demonstration Virtual Meetup#5 - Salesforce Composite Con...
MuleSoft Surat Live Demonstration Virtual Meetup#5 - Salesforce Composite Con...MuleSoft Surat Live Demonstration Virtual Meetup#5 - Salesforce Composite Con...
MuleSoft Surat Live Demonstration Virtual Meetup#5 - Salesforce Composite Con...
Jitendra Bafna
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
Sashko Stubailo
 
A quick introduction to GraphQL
A quick introduction to GraphQLA quick introduction to GraphQL
A quick introduction to GraphQL
Ashokkumar T A
 
React and GraphQL at Stripe
React and GraphQL at StripeReact and GraphQL at Stripe
React and GraphQL at Stripe
Sashko Stubailo
 
Creating web api and consuming- part 1
Creating web api and consuming- part 1Creating web api and consuming- part 1
Creating web api and consuming- part 1
Dipendra Shekhawat
 
Google cloud endpoints
Google cloud endpointsGoogle cloud endpoints
Google cloud endpoints
Dimitar Danailov
 

What's hot (20)

GraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL: The Missing Link Between Frontend and Backend DevsGraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL: The Missing Link Between Frontend and Backend Devs
 
GraphQL
GraphQLGraphQL
GraphQL
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
Angular Ivy- An Overview
Angular Ivy- An OverviewAngular Ivy- An Overview
Angular Ivy- An Overview
 
Google Cloud Enpoints
Google Cloud EnpointsGoogle Cloud Enpoints
Google Cloud Enpoints
 
Graphql
GraphqlGraphql
Graphql
 
Case Study: Integration Automation Create Delightful API Docs
Case Study: Integration Automation Create Delightful API DocsCase Study: Integration Automation Create Delightful API Docs
Case Study: Integration Automation Create Delightful API Docs
 
IVY: an overview
IVY: an overviewIVY: an overview
IVY: an overview
 
Into to GraphQL
Into to GraphQLInto to GraphQL
Into to GraphQL
 
apidays LIVE Australia 2020 - Productising your Microservices as API Products...
apidays LIVE Australia 2020 - Productising your Microservices as API Products...apidays LIVE Australia 2020 - Productising your Microservices as API Products...
apidays LIVE Australia 2020 - Productising your Microservices as API Products...
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting started
 
Taking Control of your Data with GraphQL
Taking Control of your Data with GraphQLTaking Control of your Data with GraphQL
Taking Control of your Data with GraphQL
 
Tools for designing and building great APIs
Tools for designing and building great APIsTools for designing and building great APIs
Tools for designing and building great APIs
 
GraphQL
GraphQLGraphQL
GraphQL
 
MuleSoft Surat Live Demonstration Virtual Meetup#5 - Salesforce Composite Con...
MuleSoft Surat Live Demonstration Virtual Meetup#5 - Salesforce Composite Con...MuleSoft Surat Live Demonstration Virtual Meetup#5 - Salesforce Composite Con...
MuleSoft Surat Live Demonstration Virtual Meetup#5 - Salesforce Composite Con...
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
 
A quick introduction to GraphQL
A quick introduction to GraphQLA quick introduction to GraphQL
A quick introduction to GraphQL
 
React and GraphQL at Stripe
React and GraphQL at StripeReact and GraphQL at Stripe
React and GraphQL at Stripe
 
Creating web api and consuming- part 1
Creating web api and consuming- part 1Creating web api and consuming- part 1
Creating web api and consuming- part 1
 
Google cloud endpoints
Google cloud endpointsGoogle cloud endpoints
Google cloud endpoints
 

Similar to Build Android App using GCE & GAE

Introduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentIntroduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API Development
Colin Su
 
Introduction to google endpoints
Introduction to google endpointsIntroduction to google endpoints
Introduction to google endpoints
Shinto Anto
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
wesley chun
 
Mobile backends with Google Cloud Platform (MBLTDev'14)
Mobile backends with Google Cloud Platform (MBLTDev'14)Mobile backends with Google Cloud Platform (MBLTDev'14)
Mobile backends with Google Cloud Platform (MBLTDev'14)
Natalia Efimtseva
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to Apigility
Engineor
 
Powerful Google developer tools for immediate impact! (2023-24 A)
Powerful Google developer tools for immediate impact! (2023-24 A)Powerful Google developer tools for immediate impact! (2023-24 A)
Powerful Google developer tools for immediate impact! (2023-24 A)
wesley chun
 
How to build a website that works without internet using angular, service wor...
How to build a website that works without internet using angular, service wor...How to build a website that works without internet using angular, service wor...
How to build a website that works without internet using angular, service wor...
Tomiwa Ademidun
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
SaleemMalik52
 
API workshop by AWS and 3scale
API workshop by AWS and 3scaleAPI workshop by AWS and 3scale
API workshop by AWS and 3scale
3scale
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
Kanda Runapongsa Saikaew
 
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
e-Legion
 
Integrating TypeScript with popular frameworks like React or Angular.pdf
Integrating TypeScript with popular frameworks like React or Angular.pdfIntegrating TypeScript with popular frameworks like React or Angular.pdf
Integrating TypeScript with popular frameworks like React or Angular.pdf
MobMaxime
 
Accessing Google Cloud APIs
Accessing Google Cloud APIsAccessing Google Cloud APIs
Accessing Google Cloud APIs
wesley chun
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App Engine
Vlad Filippov
 
Progressive Web Application by Citytech
Progressive Web Application by CitytechProgressive Web Application by Citytech
Progressive Web Application by Citytech
Ritwik Das
 
White Paper : ASP.NET Core AngularJs 2 and Prime
White Paper : ASP.NET Core AngularJs 2 and PrimeWhite Paper : ASP.NET Core AngularJs 2 and Prime
White Paper : ASP.NET Core AngularJs 2 and Prime
Hamida Rebai Trabelsi
 
Logic apps and PowerApps - Integrate across your APIs
Logic apps and PowerApps - Integrate across your APIsLogic apps and PowerApps - Integrate across your APIs
Logic apps and PowerApps - Integrate across your APIs
Sriram Hariharan
 
MongoDB World 2018: Building Serverless Apps with MongoDB Atlas on Google Clo...
MongoDB World 2018: Building Serverless Apps with MongoDB Atlas on Google Clo...MongoDB World 2018: Building Serverless Apps with MongoDB Atlas on Google Clo...
MongoDB World 2018: Building Serverless Apps with MongoDB Atlas on Google Clo...
MongoDB
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
wesley chun
 
How to build and deploy app on Replit
How to build and deploy app on ReplitHow to build and deploy app on Replit
How to build and deploy app on Replit
matiasfund
 

Similar to Build Android App using GCE & GAE (20)

Introduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentIntroduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API Development
 
Introduction to google endpoints
Introduction to google endpointsIntroduction to google endpoints
Introduction to google endpoints
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
 
Mobile backends with Google Cloud Platform (MBLTDev'14)
Mobile backends with Google Cloud Platform (MBLTDev'14)Mobile backends with Google Cloud Platform (MBLTDev'14)
Mobile backends with Google Cloud Platform (MBLTDev'14)
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to Apigility
 
Powerful Google developer tools for immediate impact! (2023-24 A)
Powerful Google developer tools for immediate impact! (2023-24 A)Powerful Google developer tools for immediate impact! (2023-24 A)
Powerful Google developer tools for immediate impact! (2023-24 A)
 
How to build a website that works without internet using angular, service wor...
How to build a website that works without internet using angular, service wor...How to build a website that works without internet using angular, service wor...
How to build a website that works without internet using angular, service wor...
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
 
API workshop by AWS and 3scale
API workshop by AWS and 3scaleAPI workshop by AWS and 3scale
API workshop by AWS and 3scale
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
 
Integrating TypeScript with popular frameworks like React or Angular.pdf
Integrating TypeScript with popular frameworks like React or Angular.pdfIntegrating TypeScript with popular frameworks like React or Angular.pdf
Integrating TypeScript with popular frameworks like React or Angular.pdf
 
Accessing Google Cloud APIs
Accessing Google Cloud APIsAccessing Google Cloud APIs
Accessing Google Cloud APIs
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App Engine
 
Progressive Web Application by Citytech
Progressive Web Application by CitytechProgressive Web Application by Citytech
Progressive Web Application by Citytech
 
White Paper : ASP.NET Core AngularJs 2 and Prime
White Paper : ASP.NET Core AngularJs 2 and PrimeWhite Paper : ASP.NET Core AngularJs 2 and Prime
White Paper : ASP.NET Core AngularJs 2 and Prime
 
Logic apps and PowerApps - Integrate across your APIs
Logic apps and PowerApps - Integrate across your APIsLogic apps and PowerApps - Integrate across your APIs
Logic apps and PowerApps - Integrate across your APIs
 
MongoDB World 2018: Building Serverless Apps with MongoDB Atlas on Google Clo...
MongoDB World 2018: Building Serverless Apps with MongoDB Atlas on Google Clo...MongoDB World 2018: Building Serverless Apps with MongoDB Atlas on Google Clo...
MongoDB World 2018: Building Serverless Apps with MongoDB Atlas on Google Clo...
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
 
How to build and deploy app on Replit
How to build and deploy app on ReplitHow to build and deploy app on Replit
How to build and deploy app on Replit
 

Build Android App using GCE & GAE

  • 1. Build Android App using GCE & GAE By Love Sharma
  • 2. Hello World Some introductions are in order ● If you have question, raise a hand. ● There will be dedicated Q&A time at the end of the lecture ● All source code will be provided in the form of Github link.
  • 3. Topics Today ● What is Google App engine? ● What are RESTful APIs? ● What is Google Cloud Endpoints? ● Testing API Locally / Google API Explorer ● Generate client libraries for Android / iOS ● Consuming endpoints in your android application ● Walkthrough sample tic-tac-toe project. ● Q&A
  • 4. Google App Engine ● Platform as a Service (PaaS) ● Easy to build and maintain. ● Easy to scale as the traffic and storage needs grow. ● Supported programming languages ○ Java ○ Python ○ PHP ○ Go ● Datastore ● Easily integrated with Google Cloud SQL
  • 5. When to use GAE? ● You don’t want to get troubled for setting up a server. ● You want instant for-free nearly infinite scalability support. ● You don’t feel like taking care of your own server monitoring tools. ● You need pricing that fits your actual usage and isn't time-slot based (App engine provides pay-per-drink cost model). ● You are able to chunk long tasks into 60 second pieces. ● You are able to work without direct access to local file system.
  • 6. RESTful APIs (quick recap) ● A web service, which uses HTTP as a transport. ● Central idea: there are resources which we want to export ● Resources are sent back and forth using their representation. ● REST = representational state transfer. ● Four main operations, mapped to HTTP method: ○ GET - read or list the data ○ POST - add new data ○ PUT - update existing data ○ DELETE - as follows from the name
  • 7. What is Google Cloud Endpoints? ● Easily create API backend. ● Simply Annotate your code. ● Automatically generate client libraries. ● Leverage App engine on Mobile. ● Authenticate end users. ○ OAuth 2.0 Support
  • 8. What is Google Cloud Endpoints?
  • 9. Let’s see some `code` Import messages libraries need to create a backend API. Then, the message classes are defined. These messages are used to define the requests and responses for the API Next, the sample defines the API service. The API service defines and implements the methods that are available for the API
  • 10. Let’s see some `code` This API has one methods: ● The board_get_movemethod return with a single ‘O’ added to the board passed in. Finally, the sample defines the API server which is responsible for routing requests to an individual service. APP = endpoints.api_server([TicTacToeApi])
  • 11. Running and testing your backend API In the project directory, start the development server: ~/path/to/python/sdk/google_appengine/dev_appserver.py . When the backend is running successfully, a message similar to this one is displayed: INFO 2013-10-07 19:41:16,687 admin_server.py:117] Starting admin server at: http://localhost: 8000 In your browser, visit this URL: http://localhost:8080/_ah/api/explorer
  • 12. API Explorer A. Click tictactoe to display the available methods. B. Click tictactoe.board.getmove to display the Explorer form for it. C. Select state from Request body and enter current state of tic-tac-toe board e.g., “X--------” D. Execute in order to get next “O” move. E. Notice the display of the request and response. In the Response, you'll see the OK result and the returned message, “XO-------”.
  • 13. Generate Client Libraries Invoke the Endpoints command line tool as follows: google_appengine/endpointscfg.py get_client_lib java -bs desired_client_bundle your_module. YourServiceClass Using a more concrete example to generate the client library: google_appengine/endpointscfg.py get_client_lib java -bs gradle tictactoe_api.TicTacToeApi When successful, the tool displays a message similar to: API client library written to ./tictactoe-v1.zip
  • 14. Consuming endpoints in your android app To add the client library to the Android project: ● Add a /libs directory to your project if it doesn't already have one. It should be a peer to the /src directory. ● Copy the client library generated from the backend API into /libs. ● Select the library you just added, right-click, then select Add As Library to your project.
  • 15. Let’s integrate... Creating the service object In your project code, you must use a service object to make requests to the backend API. For unauthenticated requests, construct the service object as follows: Calling the backend API In your project, call the API using the service object. In the snippet, we are requesting a list of all Score objects on the server. If list required parameters, or a request body, you would provide them in the invocation. Android Studio provides code completion to identity available method calls, and their required parameters.
  • 16. Let’s integrate... Note: It is important to note that because API calls result in requests over the network, you are required to make requests in their own thread. (This requirement was added to recent versions of Android, but it is a best practice even in older versions.) To do this, you use a Thread or AsyncTask. For example:
  • 17. Q & A
  • 18. References ● https://cloud.google.com/endpoints/ ● https://cloud.google.com/appengine/docs/python/endpoints/ ● https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe- python ● https://console.developers.google.com ● https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe- android