Introduction to Google Cloud Endpoints: Speed Up Your API Development
-
Upload
colin-su -
Category
Technology
-
view
1.227 -
download
5
description
Transcript of Introduction to Google Cloud Endpoints: Speed Up Your API Development
![Page 1: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/1.jpg)
GDG Taipei
GDG Taipei
Google Cloud EndpointsSpeed Up Your API Development
+Colin Su
Google Developer Expert - Cloud Platform
![Page 2: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/2.jpg)
GDG Taipei
About +ColinDeveloper Expert, Google Cloud Platform
Organizer of GDG Taipei
Software Engineer at Tagtoo
http://about.me/littleQ
![Page 3: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/3.jpg)
GDG Taipei
Agenda
What's Google Cloud Endpoints?
Instance of Google Cloud Endpoints
What Else?
1
2
3
![Page 4: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/4.jpg)
GDG Taipei
Google App Engine
Platform-as-a-Service at Google
Deploy your application code, take advantage of the infrastructure from Google
Easy to build, easy to run, easy to scale
Your CodeScalable
Service
![Page 5: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/5.jpg)
GDG Taipei
Build Server side logic on full power, management free App Engine platform
Expose standards based REST interfaces with built in Authorization
Use auto-generated, strongly typed, mobile optimized client libraries for Android, iOS and web
Publish and manage all your API in your project internally without additional works
Cloud Endpoints
![Page 6: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/6.jpg)
GDG Taipei
How It Works
![Page 7: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/7.jpg)
GDG Taipei
Server-Side (API Service) Support
Python
Java
Go
PHP
![Page 8: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/8.jpg)
GDG Taipei
API Explorer
developers.google.com/apis-explorer
APIs Discovery Service
![Page 9: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/9.jpg)
GDG Taipei
API Explorer
Testing API made easy
![Page 10: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/10.jpg)
GDG Taipei
Agenda
What's Google Cloud Endpoints?
Instance of Google Cloud Endpoints
What Else?
1
2
3
![Page 11: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/11.jpg)
GDG Taipei
Endpoints Progress (Server-side)
Define your request and response messages
Make a API service
Implement your method, bound it with specified req/resp messages
Deploy your App Engine project
![Page 12: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/12.jpg)
GDG Taipei
Let's step through the example of server-side Endpoints
![Page 13: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/13.jpg)
GDG Taipei
First, I'm going to define the format of input and output first
import endpointsfrom protorpc import messages, remote
class StringMsg(messages.Message): """ Your request message model """ msg = messages.StringField(1)
class StringListMsg(messages.Message): """ Your response message model """ items = messages.StringField(1, repeated=True)
Google Protocol Buffer: https://developers.google.com/protocol-buffers/
![Page 14: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/14.jpg)
GDG Taipei
then define an API, I decided to call it String API.
@endpoints.api( name='stringapi', version='v1', description='Your first string API')class StringApi(remote.Service): ...
![Page 15: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/15.jpg)
GDG Taipei
Almost done, just need a method to describe what this api does...
@endpoints.method( StringMsg, StringListMsg) def split(self, request): msg = request.msg # request will be a StringMsg instance here splitted = msg.split() # SPLIT! one line of code return StringListMsg(items=splitted) # just return an instance of StringListMsg
![Page 16: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/16.jpg)
GDG Taipei
Yeah, IT WORKS. (not only on my machine)
![Page 17: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/17.jpg)
GDG Taipei
Choose Your Client Libraries
For client library, you got choices:
● Generate your own
● Use Google APIs Client Library (this is the same way how you use other Google APIs)
![Page 18: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/18.jpg)
GDG Taipei
Generate Your Own Library
Endpoints now support generating packaged library for these platform
● Android● iOS
by Using Endpoints Command Line Tool: endpointscfg.py
For others, you will need to load clients via Google APIs Client Libraries
Generate Client Libraries: https://developers.google.com/appengine/docs/python/endpoints/gen_clients
![Page 19: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/19.jpg)
GDG Taipei
Google APIs Client Library
Programming Languages Support:
● Java● JavaScript● Python● .NET● PHP● Objective-C
Go, Node.js and Ruby supports are on the way, check out Google APIs Client Library
![Page 20: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/20.jpg)
GDG Taipei
Agenda
What's Google Cloud Endpoints?
Instance of Google Cloud Endpoints
What Else?
1
2
3
![Page 21: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/21.jpg)
GDG Taipei
Model-based Endpoints
RESTful API are usually bound with models
github.com/GoogleCloudPlatform/endpoints-proto-datastore
Message-free endpoints development
@endpoints.method(MyModelMessage, MyModelMessage, path='mymodel', http_method='POST', name='mymodel.insert')def InsertModel(self, request): my_model = MyModel(attr1=request.attr1, attr2=request.attr2, ...) transformed_model = DoSomething(my_model) return MyModelMessage(attr1=transformed_model.attr1, attr2=transformed_model.attr2, ...)
![Page 22: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/22.jpg)
GDG Taipei
Endpoints Model
from endpoints_proto_datastore.ndb import EndpointsModel
class MyModel(EndpointsModel): attr1 = ndb.StringProperty() attr2 = ndb.StringProperty() created = ndb.DateTimeProperty(auto_now_add=True)
![Page 23: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/23.jpg)
GDG Taipei
Define POST Method for Model
@MyModel.method(path='mymodel', http_method='POST', name='mymodel.insert')def MyModelInsert(self, my_model): my_model.put() return my_model
![Page 24: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/24.jpg)
GDG Taipei
Define Query Method for Model
@MyModel.query_method(path='mymodels', name='mymodel.list')def MyModelList(self, query): # filter your query... return query
![Page 25: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/25.jpg)
GDG Taipei
![Page 26: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/26.jpg)
GDG Taipei
Resources
http://googlecloudplatform.github.io/ , then search "endpoint"
http://github.com/googlecloudplatform?query=endpoint
![Page 27: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/27.jpg)
GDG Taipei
Highlighted Projects on Github
Getting Started:
● Hello Endpoints {Python, Java}: for server-side development
● Hello Endpoints {iOS, Android}: for client libraries usage
Getting Advanced:
● appengine-endpoints-angular-todos-python
● appengine-endpoints-tictactoe-python
● appengine-endpoints-tictactoe-java-maven
![Page 28: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/28.jpg)
Recent UpdatesInformation About Upcoming Events
![Page 29: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/29.jpg)
GDG Taipei
GDG TaipeiGoogle Developer Group Taipei (previously GTUG)
Speakers wanted for regular meetup, DevFest
+GTUGTaipei
http://www.gdg-taipei.org/
![Page 30: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/30.jpg)
GDG Taipei
Google I/O Extended TaipeiJune 25 evening
8:00 PM ~ 2:00 AM
venue is TBA
● Watch Keynote Live together
● Sessions
○ Android, Google Glass
○ Google Cloud Platform
● Food, Drink...
Keep your eyes on GDG Taipei pages
![Page 31: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/31.jpg)
Interested?Go to http://cloud.google.com for more information
+ColinSu@littleq0903http://about.me/littleQ
![Page 32: Introduction to Google Cloud Endpoints: Speed Up Your API Development](https://reader033.fdocuments.us/reader033/viewer/2022042601/554bc187b4c90530298b515d/html5/thumbnails/32.jpg)
Google confidential │ Do not distribute
cloud.google.com
Images by Connie Zhou