SlideShare a Scribd company logo
App Engine
Cloud Endpoints
@d_danailov
Google App Engine
Dimitar Danailov
Senior Developer at 158ltd.com
dimityr.danailov[at]gmail.com
Slideshare.net
Github
YouTube
Founder at VarnaIT
Topics Today
● Overview
● Architecture
● Software
● Java JDO support
● Commands
● Google API Explorer
● CustomizeREST Interface
Overview
Google Cloud Endpoints consists of tools, libraries and capabilities that
allow you to generate APIs and client libraries from an App Engine
application, referred to as an API backend, to simplify client access to
data from other applications. Endpoints makes it easier to create a web
backend for web clients and mobile clients such as Android or Apple's
iOS.
Basic Endpoints
Architecture
Software
Demo Project
Beer Class
public class Beer {
private Long id ;
private String beerName ;
private String kindOfBeer ;
private Long score ;
private Long numberOfDrinks ;
private Text image ;
private String country ;
private String description ;
private Double latitude ;
private Double longitude ;
public Long getId () {
return id ;
}
public void setId ( Long id ) {
this . id = id ;
}
// Getter and Setters
}
Java Data Objects (JDO) is a specification of Java object persistence.
One of its features is a transparency of the persistence services to the
domain model. JDO persistent objects are ordinary Java programming
language classes (POJOs); there is no requirement for them to
implement certain interfaces or extend from special classes.
Java JDO support
import javax.jdo.annotations.IdGeneratorStrategy ;
import javax.jdo.annotations.IdentityType ;
import javax.jdo.annotations.PersistenceCapable ;
import javax.jdo.annotations.Persistent ;
import javax.jdo.annotations.PrimaryKey ;
@PersistenceCapable ( identityType = IdentityType. APPLICATION )
public class Beer {
@PrimaryKey
@Persistent ( valueStrategy = IdGeneratorStrategy. IDENTITY )
private Long id ;
Java JDO support (2)
@Api(name = "birra")
In line 1 above we use the @Api attribute.
This attribute tells App Engine to expose this class as a RESTRPC
endpoints.
Be aware that all the public methods on this class will be accessible via
REST endpoint.
I have also changed the name to birra to match with the rest of the
application.
@Api
1. List Beers
a. curl http://localhost:8888/_ah/api/birra/v1/beer
2. Create a Bear
a. curl -H 'Content-Type: appilcation/json' -d
'{"beerName": "bud"}' http://localhost:
8888/_ah/api/birra/v1/beer
3. Get a Beer
a. curl http://localhost:8888/_ah/api/birra/v1/beer/1
Commands
@ApiMethod(name = "insertBeer")
public Beer insertBeer (Beer beer) {
PersistenceManager mgr = getPersistenceManager ();
try {
if (containsCar(beer)) {
throw new EntityExistsException ("Object already exists ");
}
mgr.makePersistent (beer);
} finally {
mgr.close();
}
return beer;
}
Fix - Before
@ApiMethod(name = "insertBeer")
public Beer insertBeer (Beer beer) {
PersistenceManager mgr = getPersistenceManager ();
try {
if (beer.getId() != null) {
if (containsCar(beer)) {
throw new EntityExistsException ("Object already
exists");
}
}
mgr.makePersistent (beer);
} finally {
mgr.close();
}
return beer;
}
Fix - After
https://<appid>.appspot.
com/_ah/api/discovery/v1/apis
Google API
Explorer
https://<appid>.
appspot.
com/_ah/api/expl
orer
Comment Class
import com.google.appengine.api.users.User;
import javax.jdo.annotations.IdGeneratorStrategy ;
import javax.jdo.annotations.IdentityType ;
import javax.jdo.annotations.PersistenceCapable ;
import javax.jdo.annotations.Persistent ;
import javax.jdo.annotations.PrimaryKey ;
@PersistenceCapable (identityType = IdentityType.APPLICATION)
public class Comment {
@PrimaryKey
@Persistent ( valueStrategy = IdGeneratorStrategy . IDENTITY
)
private Long commentId;
private User user;
private String date;
private Long beerId;
private String comment;
// Getter and Setters
}
Customize
REST Interface
@ApiMethod(name = "beers.comments.list", path =
"beers/{beerId}/comments")
public CollectionResponse < Comment > listComment(
@Named("beerId") Long beerId,
@Nullable@ Named("cursor") String cursorString,
@Nullable@ Named("limit") Integer limit) {
PersistenceManager mgr = null;
Cursor cursor = null;
List < Comment > execute = null;
try {
mgr = getPersistenceManager();
Query query = mgr.newQuery(Comment.class,
"beerId == " + beerId);
// ...
@ApiMethod(name = "beers.get.comment", path =
"beers/{beerId}/comments/{id}")
public Comment getComment(@Named("beerId") Long
beerId, @Named("id") Long id) {
@ApiMethod(name = "beers.comments.insert", path =
"beers/{beerId}/comments")
public Comment insertComment(@Named ( "beerId" )
Long beerId, Comment comment) {
Customize REST Interface (2)
private static final Index INDEX = getIndex();
private static Index getIndex() {
IndexSpec indexSpec = IndexSpec.newBuilder()
.setName("beerindex").build();
Index indexServiceFactory =
SearchServiceFactory.getSearchService().getIndex
(indexSpec);
return indexServiceFactory;
}
Search
Add Beers to that Index
private static void addBeerToSearchIndex(Beer beer) {
Document.Builder docBuilder = Document.newBuilder();
/*** Id ***/
Long beerId = beer.getId();
docBuilder .addField(Field.newBuilder().setName("id").setText
(Long.toString(beerId)));
/*** Name ***/
String beerName = beer.getBeerName();
String docBuilderName = "";
if (beerName != null) {
docBuilderName = beerName;
}
docBuilder .addField(Field.newBuilder().setName("name").setText
(docBuilderName ));
/*** Name ***/
/*** … ***/
private static void addBeerToSearchIndex(Beer beer) {
/*** … ***/
/*** Latitude ***/
Double beerLatitude = beer.getLatitude();
Double docBulderLatitude = (double) 0;
if (beerLatitude != null) {
docBulderLatitude = beerLatitude;
}
docBuilder .addField(Field.newBuilder().setName("latitude").setNumber
(docBulderLatitude ));
/*** Latitude ***/
/*** Score ***/
Long beerScore = beer.getScore();
Long docBuilderScore = (long) 0;
if (beerScore != null) {
docBuilderScore = beerScore;
}
docBuilder.addField(Field.newBuilder().setName("score").
setNumber(docBuilderScore));
/*** Score ***/
docBuilder.addField(Field.newBuilder().setName("published").
setDate(new Date()));
docBuilder.setId(Long.toString(beerId));
Document document = docBuilder.build();
INDEX.put(document);
}
Search
@ApiMethod(httpMethod = "GET", name = "beer.search")
public List < Beer > searchBeer(@Named("term") String queryString) {
List < Beer > beerList = new ArrayList < Beer > ();
Results < ScoredDocument > results = INDEX.search(queryString);
for (ScoredDocument scoredDoc : results) {
try {
Field f = scoredDoc.getOnlyField("id");
if (f == null || f.getText() == null) continue;
long beerId = Long.parseLong(f.getText());
if (beerId != -1) {
Beer b = getBeer(beerId);
beerList .add(b);
}
} catch (Exception e) {
e.printStackTrace ();
}
}
return beerList;
Tutorials
● Overview of Google Cloud Endpoints
● Deploy the Backend
● HTML5 and App Engine: The Epic Tag Team Take on Modern
Web Apps at Scale
● GDC 2013 - Connect Mobile Apps to the Cloud Without Breaking
a Sweat
● Google Cloud Endpoints - Varna Lab 25.09.2013
Source
● http://www.networkworld.com
● http://upload.wikimedia.org
● http://cdn.techinasia.com
● http://en.wikipedia.org
● https://developers.google.com/
● http://www.bg-mamma.com/
● http://stackoverflow.com/
● https://www.youtube.com
Questions ?
Dimitar Danailov
Senior Developer at 158ltd.com
dimityr.danailov[at]gmail.com
Slideshare.net
Github
YouTube
Founder at VarnaIT

More Related Content

What's hot

Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
Christoffer Noring
 
TDC2016SP - Trilha Android
TDC2016SP - Trilha AndroidTDC2016SP - Trilha Android
TDC2016SP - Trilha Android
tdc-globalcode
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
Muhammad Hafiz Hasan
 
Android dev tips
Android dev tipsAndroid dev tips
Android dev tips
Kanda Runapongsa Saikaew
 
Angular 8
Angular 8 Angular 8
Angular 8
Sunil OS
 
Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2
Christoffer Noring
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introduction
Commit University
 
Angular IO
Angular IOAngular IO
Angular IO
Jennifer Estrada
 
Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony Container
Diego Lewin
 
Hilt Annotations
Hilt AnnotationsHilt Annotations
Hilt Annotations
Ali Göktaş
 
Apigee Console & eZ Publish REST
Apigee Console & eZ Publish RESTApigee Console & eZ Publish REST
Apigee Console & eZ Publish REST
lserwatka
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101
Rich Helton
 
Azure mobile apps
Azure mobile appsAzure mobile apps
Azure mobile apps
David Giard
 
Sharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFSharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SF
Pierre-Yves Ricau
 
Extend sdk
Extend sdkExtend sdk
Extend sdk
Harsha Nagaraj
 
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
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniter
Ahmad Arif
 
Building a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesBuilding a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web Services
David Giard
 
Quick Start to iOS Development
Quick Start to iOS DevelopmentQuick Start to iOS Development
Quick Start to iOS Development
Jussi Pohjolainen
 
Technozaure - Angular2
Technozaure - Angular2Technozaure - Angular2
Technozaure - Angular2
Demey Emmanuel
 

What's hot (20)

Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 
TDC2016SP - Trilha Android
TDC2016SP - Trilha AndroidTDC2016SP - Trilha Android
TDC2016SP - Trilha Android
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
 
Android dev tips
Android dev tipsAndroid dev tips
Android dev tips
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introduction
 
Angular IO
Angular IOAngular IO
Angular IO
 
Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony Container
 
Hilt Annotations
Hilt AnnotationsHilt Annotations
Hilt Annotations
 
Apigee Console & eZ Publish REST
Apigee Console & eZ Publish RESTApigee Console & eZ Publish REST
Apigee Console & eZ Publish REST
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101
 
Azure mobile apps
Azure mobile appsAzure mobile apps
Azure mobile apps
 
Sharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFSharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SF
 
Extend sdk
Extend sdkExtend sdk
Extend sdk
 
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
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniter
 
Building a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesBuilding a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web Services
 
Quick Start to iOS Development
Quick Start to iOS DevelopmentQuick Start to iOS Development
Quick Start to iOS Development
 
Technozaure - Angular2
Technozaure - Angular2Technozaure - Angular2
Technozaure - Angular2
 

Similar to Google Cloud Endpoints - Soft Uni 19.06.2014

apiDoc Introduction
apiDoc IntroductionapiDoc Introduction
apiDoc Introduction
Peter Rottmann
 
Making Things Work Together
Making Things Work TogetherMaking Things Work Together
Making Things Work Together
Subbu Allamaraju
 
Building an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and FirebaseBuilding an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and Firebase
Marina Coelho
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
Tom Johnson
 
SP Rest API Documentation
SP Rest API DocumentationSP Rest API Documentation
SP Rest API Documentation
IT Industry
 
Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.pdf
ShaiAlmog1
 
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB
 
Cgi
CgiCgi
How to build RESTful API in 15 Minutes.pptx
How to build RESTful API in 15 Minutes.pptxHow to build RESTful API in 15 Minutes.pptx
How to build RESTful API in 15 Minutes.pptx
Linx
 
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
AWS Chicago
 
Gears User Guide
Gears User GuideGears User Guide
Gears User Guide
Muthuselvam RS
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
維佋 唐
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
Amzad Hossain
 
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin PickinItb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Gavin Pickin
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
Remy Sharp
 
Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
sreedath c g
 
ApacheCon Testing Camel K with Cloud Native BDD
ApacheCon Testing Camel K with Cloud Native BDDApacheCon Testing Camel K with Cloud Native BDD
ApacheCon Testing Camel K with Cloud Native BDD
christophd
 
Coocoo for Cocoapods
Coocoo for CocoapodsCoocoo for Cocoapods
Coocoo for Cocoapods
Allan Davis
 
Red5 - PHUG Workshops
Red5 - PHUG WorkshopsRed5 - PHUG Workshops
Red5 - PHUG Workshops
Brendan Sera-Shriar
 
Integrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalIntegrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere Portal
Himanshu Mendiratta
 

Similar to Google Cloud Endpoints - Soft Uni 19.06.2014 (20)

apiDoc Introduction
apiDoc IntroductionapiDoc Introduction
apiDoc Introduction
 
Making Things Work Together
Making Things Work TogetherMaking Things Work Together
Making Things Work Together
 
Building an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and FirebaseBuilding an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and Firebase
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
SP Rest API Documentation
SP Rest API DocumentationSP Rest API Documentation
SP Rest API Documentation
 
Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.pdf
 
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
 
Cgi
CgiCgi
Cgi
 
How to build RESTful API in 15 Minutes.pptx
How to build RESTful API in 15 Minutes.pptxHow to build RESTful API in 15 Minutes.pptx
How to build RESTful API in 15 Minutes.pptx
 
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 
Gears User Guide
Gears User GuideGears User Guide
Gears User Guide
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin PickinItb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin Pickin
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
 
Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
 
ApacheCon Testing Camel K with Cloud Native BDD
ApacheCon Testing Camel K with Cloud Native BDDApacheCon Testing Camel K with Cloud Native BDD
ApacheCon Testing Camel K with Cloud Native BDD
 
Coocoo for Cocoapods
Coocoo for CocoapodsCoocoo for Cocoapods
Coocoo for Cocoapods
 
Red5 - PHUG Workshops
Red5 - PHUG WorkshopsRed5 - PHUG Workshops
Red5 - PHUG Workshops
 
Integrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalIntegrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere Portal
 

More from Dimitar Danailov

Evolution - ReConnect() 2019
Evolution - ReConnect() 2019Evolution - ReConnect() 2019
Evolution - ReConnect() 2019
Dimitar Danailov
 
Data Visualization and D3Js
Data Visualization and D3JsData Visualization and D3Js
Data Visualization and D3Js
Dimitar Danailov
 
#Productivity - {S:01 Ep:03}
#Productivity - {S:01 Ep:03} #Productivity - {S:01 Ep:03}
#Productivity - {S:01 Ep:03}
Dimitar Danailov
 
#Productivity - {S:01 Ep:02}
#Productivity - {S:01 Ep:02}#Productivity - {S:01 Ep:02}
#Productivity - {S:01 Ep:02}
Dimitar Danailov
 
#Productivity s01 ep02
#Productivity s01 ep02#Productivity s01 ep02
#Productivity s01 ep02
Dimitar Danailov
 
#Productivity s01 ep01
#Productivity s01 ep01#Productivity s01 ep01
#Productivity s01 ep01
Dimitar Danailov
 
Cloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functionsCloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functions
Dimitar Danailov
 
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
Dimitar Danailov
 
Building modern Progressive Web Apps with Polymer
Building modern Progressive Web Apps with PolymerBuilding modern Progressive Web Apps with Polymer
Building modern Progressive Web Apps with Polymer
Dimitar Danailov
 
Typescript - MentorMate Academy
Typescript - MentorMate AcademyTypescript - MentorMate Academy
Typescript - MentorMate Academy
Dimitar Danailov
 
HackConf2016 - Ruby on Rails: Unexpected journey
HackConf2016 - Ruby on Rails: Unexpected journeyHackConf2016 - Ruby on Rails: Unexpected journey
HackConf2016 - Ruby on Rails: Unexpected journey
Dimitar Danailov
 
Microservices - Code Voyagers Sofia
Microservices - Code Voyagers SofiaMicroservices - Code Voyagers Sofia
Microservices - Code Voyagers Sofia
Dimitar Danailov
 
Mongo DB Terms - Mentormate Academy
Mongo DB Terms - Mentormate AcademyMongo DB Terms - Mentormate Academy
Mongo DB Terms - Mentormate Academy
Dimitar Danailov
 
Startup Europe Week - Cloud Conf Varna & GDG Varna
Startup Europe Week - Cloud Conf Varna & GDG VarnaStartup Europe Week - Cloud Conf Varna & GDG Varna
Startup Europe Week - Cloud Conf Varna & GDG Varna
Dimitar Danailov
 
GDG Varna - Hadoop
GDG Varna - HadoopGDG Varna - Hadoop
GDG Varna - Hadoop
Dimitar Danailov
 
MicroServices: Advantages ans Disadvantages
MicroServices: Advantages ans DisadvantagesMicroServices: Advantages ans Disadvantages
MicroServices: Advantages ans Disadvantages
Dimitar Danailov
 
GDG Varna - EcmaScript 6
GDG Varna - EcmaScript 6GDG Varna - EcmaScript 6
GDG Varna - EcmaScript 6
Dimitar Danailov
 
Softuni.bg - Microservices
Softuni.bg - MicroservicesSoftuni.bg - Microservices
Softuni.bg - Microservices
Dimitar Danailov
 
Cloud Conf Varna: Vagrant and Amazon
Cloud Conf Varna: Vagrant and AmazonCloud Conf Varna: Vagrant and Amazon
Cloud Conf Varna: Vagrant and Amazon
Dimitar Danailov
 
HackConf2015 - Ruby on Rails: Unexpected journey
HackConf2015 - Ruby on Rails: Unexpected journeyHackConf2015 - Ruby on Rails: Unexpected journey
HackConf2015 - Ruby on Rails: Unexpected journey
Dimitar Danailov
 

More from Dimitar Danailov (20)

Evolution - ReConnect() 2019
Evolution - ReConnect() 2019Evolution - ReConnect() 2019
Evolution - ReConnect() 2019
 
Data Visualization and D3Js
Data Visualization and D3JsData Visualization and D3Js
Data Visualization and D3Js
 
#Productivity - {S:01 Ep:03}
#Productivity - {S:01 Ep:03} #Productivity - {S:01 Ep:03}
#Productivity - {S:01 Ep:03}
 
#Productivity - {S:01 Ep:02}
#Productivity - {S:01 Ep:02}#Productivity - {S:01 Ep:02}
#Productivity - {S:01 Ep:02}
 
#Productivity s01 ep02
#Productivity s01 ep02#Productivity s01 ep02
#Productivity s01 ep02
 
#Productivity s01 ep01
#Productivity s01 ep01#Productivity s01 ep01
#Productivity s01 ep01
 
Cloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functionsCloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functions
 
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
 
Building modern Progressive Web Apps with Polymer
Building modern Progressive Web Apps with PolymerBuilding modern Progressive Web Apps with Polymer
Building modern Progressive Web Apps with Polymer
 
Typescript - MentorMate Academy
Typescript - MentorMate AcademyTypescript - MentorMate Academy
Typescript - MentorMate Academy
 
HackConf2016 - Ruby on Rails: Unexpected journey
HackConf2016 - Ruby on Rails: Unexpected journeyHackConf2016 - Ruby on Rails: Unexpected journey
HackConf2016 - Ruby on Rails: Unexpected journey
 
Microservices - Code Voyagers Sofia
Microservices - Code Voyagers SofiaMicroservices - Code Voyagers Sofia
Microservices - Code Voyagers Sofia
 
Mongo DB Terms - Mentormate Academy
Mongo DB Terms - Mentormate AcademyMongo DB Terms - Mentormate Academy
Mongo DB Terms - Mentormate Academy
 
Startup Europe Week - Cloud Conf Varna & GDG Varna
Startup Europe Week - Cloud Conf Varna & GDG VarnaStartup Europe Week - Cloud Conf Varna & GDG Varna
Startup Europe Week - Cloud Conf Varna & GDG Varna
 
GDG Varna - Hadoop
GDG Varna - HadoopGDG Varna - Hadoop
GDG Varna - Hadoop
 
MicroServices: Advantages ans Disadvantages
MicroServices: Advantages ans DisadvantagesMicroServices: Advantages ans Disadvantages
MicroServices: Advantages ans Disadvantages
 
GDG Varna - EcmaScript 6
GDG Varna - EcmaScript 6GDG Varna - EcmaScript 6
GDG Varna - EcmaScript 6
 
Softuni.bg - Microservices
Softuni.bg - MicroservicesSoftuni.bg - Microservices
Softuni.bg - Microservices
 
Cloud Conf Varna: Vagrant and Amazon
Cloud Conf Varna: Vagrant and AmazonCloud Conf Varna: Vagrant and Amazon
Cloud Conf Varna: Vagrant and Amazon
 
HackConf2015 - Ruby on Rails: Unexpected journey
HackConf2015 - Ruby on Rails: Unexpected journeyHackConf2015 - Ruby on Rails: Unexpected journey
HackConf2015 - Ruby on Rails: Unexpected journey
 

Recently uploaded

Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
Boost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management AppsBoost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management Apps
Jhone kinadey
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
kalichargn70th171
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
sandeepmenon62
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
Envertis Software Solutions
 
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and MoreManyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
narinav14
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
Reetu63
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
alowpalsadig
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
DevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps ServicesDevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps Services
seospiralmantra
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
Paul Brebner
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
Severalnines
 

Recently uploaded (20)

Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
Boost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management AppsBoost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management Apps
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
 
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and MoreManyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
DevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps ServicesDevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps Services
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
 

Google Cloud Endpoints - Soft Uni 19.06.2014

  • 2. Google App Engine Dimitar Danailov Senior Developer at 158ltd.com dimityr.danailov[at]gmail.com Slideshare.net Github YouTube Founder at VarnaIT
  • 3.
  • 4.
  • 5. Topics Today ● Overview ● Architecture ● Software ● Java JDO support ● Commands ● Google API Explorer ● CustomizeREST Interface
  • 6. Overview Google Cloud Endpoints consists of tools, libraries and capabilities that allow you to generate APIs and client libraries from an App Engine application, referred to as an API backend, to simplify client access to data from other applications. Endpoints makes it easier to create a web backend for web clients and mobile clients such as Android or Apple's iOS.
  • 8.
  • 9.
  • 12.
  • 14. public class Beer { private Long id ; private String beerName ; private String kindOfBeer ; private Long score ; private Long numberOfDrinks ; private Text image ; private String country ; private String description ; private Double latitude ; private Double longitude ; public Long getId () { return id ; } public void setId ( Long id ) { this . id = id ; } // Getter and Setters }
  • 15. Java Data Objects (JDO) is a specification of Java object persistence. One of its features is a transparency of the persistence services to the domain model. JDO persistent objects are ordinary Java programming language classes (POJOs); there is no requirement for them to implement certain interfaces or extend from special classes. Java JDO support
  • 16. import javax.jdo.annotations.IdGeneratorStrategy ; import javax.jdo.annotations.IdentityType ; import javax.jdo.annotations.PersistenceCapable ; import javax.jdo.annotations.Persistent ; import javax.jdo.annotations.PrimaryKey ; @PersistenceCapable ( identityType = IdentityType. APPLICATION ) public class Beer { @PrimaryKey @Persistent ( valueStrategy = IdGeneratorStrategy. IDENTITY ) private Long id ; Java JDO support (2)
  • 17.
  • 18. @Api(name = "birra") In line 1 above we use the @Api attribute. This attribute tells App Engine to expose this class as a RESTRPC endpoints. Be aware that all the public methods on this class will be accessible via REST endpoint. I have also changed the name to birra to match with the rest of the application. @Api
  • 19. 1. List Beers a. curl http://localhost:8888/_ah/api/birra/v1/beer 2. Create a Bear a. curl -H 'Content-Type: appilcation/json' -d '{"beerName": "bud"}' http://localhost: 8888/_ah/api/birra/v1/beer 3. Get a Beer a. curl http://localhost:8888/_ah/api/birra/v1/beer/1 Commands
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. @ApiMethod(name = "insertBeer") public Beer insertBeer (Beer beer) { PersistenceManager mgr = getPersistenceManager (); try { if (containsCar(beer)) { throw new EntityExistsException ("Object already exists "); } mgr.makePersistent (beer); } finally { mgr.close(); } return beer; } Fix - Before
  • 26. @ApiMethod(name = "insertBeer") public Beer insertBeer (Beer beer) { PersistenceManager mgr = getPersistenceManager (); try { if (beer.getId() != null) { if (containsCar(beer)) { throw new EntityExistsException ("Object already exists"); } } mgr.makePersistent (beer); } finally { mgr.close(); } return beer; } Fix - After
  • 29.
  • 31. import com.google.appengine.api.users.User; import javax.jdo.annotations.IdGeneratorStrategy ; import javax.jdo.annotations.IdentityType ; import javax.jdo.annotations.PersistenceCapable ; import javax.jdo.annotations.Persistent ; import javax.jdo.annotations.PrimaryKey ; @PersistenceCapable (identityType = IdentityType.APPLICATION) public class Comment { @PrimaryKey @Persistent ( valueStrategy = IdGeneratorStrategy . IDENTITY ) private Long commentId; private User user; private String date; private Long beerId; private String comment; // Getter and Setters }
  • 33. @ApiMethod(name = "beers.comments.list", path = "beers/{beerId}/comments") public CollectionResponse < Comment > listComment( @Named("beerId") Long beerId, @Nullable@ Named("cursor") String cursorString, @Nullable@ Named("limit") Integer limit) { PersistenceManager mgr = null; Cursor cursor = null; List < Comment > execute = null; try { mgr = getPersistenceManager(); Query query = mgr.newQuery(Comment.class, "beerId == " + beerId); // ...
  • 34. @ApiMethod(name = "beers.get.comment", path = "beers/{beerId}/comments/{id}") public Comment getComment(@Named("beerId") Long beerId, @Named("id") Long id) { @ApiMethod(name = "beers.comments.insert", path = "beers/{beerId}/comments") public Comment insertComment(@Named ( "beerId" ) Long beerId, Comment comment) { Customize REST Interface (2)
  • 35.
  • 36.
  • 37. private static final Index INDEX = getIndex(); private static Index getIndex() { IndexSpec indexSpec = IndexSpec.newBuilder() .setName("beerindex").build(); Index indexServiceFactory = SearchServiceFactory.getSearchService().getIndex (indexSpec); return indexServiceFactory; } Search
  • 38. Add Beers to that Index
  • 39. private static void addBeerToSearchIndex(Beer beer) { Document.Builder docBuilder = Document.newBuilder(); /*** Id ***/ Long beerId = beer.getId(); docBuilder .addField(Field.newBuilder().setName("id").setText (Long.toString(beerId))); /*** Name ***/ String beerName = beer.getBeerName(); String docBuilderName = ""; if (beerName != null) { docBuilderName = beerName; } docBuilder .addField(Field.newBuilder().setName("name").setText (docBuilderName )); /*** Name ***/ /*** … ***/
  • 40. private static void addBeerToSearchIndex(Beer beer) { /*** … ***/ /*** Latitude ***/ Double beerLatitude = beer.getLatitude(); Double docBulderLatitude = (double) 0; if (beerLatitude != null) { docBulderLatitude = beerLatitude; } docBuilder .addField(Field.newBuilder().setName("latitude").setNumber (docBulderLatitude )); /*** Latitude ***/
  • 41. /*** Score ***/ Long beerScore = beer.getScore(); Long docBuilderScore = (long) 0; if (beerScore != null) { docBuilderScore = beerScore; } docBuilder.addField(Field.newBuilder().setName("score"). setNumber(docBuilderScore)); /*** Score ***/
  • 44. @ApiMethod(httpMethod = "GET", name = "beer.search") public List < Beer > searchBeer(@Named("term") String queryString) { List < Beer > beerList = new ArrayList < Beer > (); Results < ScoredDocument > results = INDEX.search(queryString); for (ScoredDocument scoredDoc : results) { try { Field f = scoredDoc.getOnlyField("id"); if (f == null || f.getText() == null) continue; long beerId = Long.parseLong(f.getText()); if (beerId != -1) { Beer b = getBeer(beerId); beerList .add(b); } } catch (Exception e) { e.printStackTrace (); } } return beerList;
  • 45. Tutorials ● Overview of Google Cloud Endpoints ● Deploy the Backend ● HTML5 and App Engine: The Epic Tag Team Take on Modern Web Apps at Scale ● GDC 2013 - Connect Mobile Apps to the Cloud Without Breaking a Sweat ● Google Cloud Endpoints - Varna Lab 25.09.2013
  • 46. Source ● http://www.networkworld.com ● http://upload.wikimedia.org ● http://cdn.techinasia.com ● http://en.wikipedia.org ● https://developers.google.com/ ● http://www.bg-mamma.com/ ● http://stackoverflow.com/ ● https://www.youtube.com
  • 47.
  • 48. Questions ? Dimitar Danailov Senior Developer at 158ltd.com dimityr.danailov[at]gmail.com Slideshare.net Github YouTube Founder at VarnaIT