SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
Cloud Endpoints
@d_danailov
Google Clound Endpoints
Dimitar Danailov
Senior Developer at 158ltd.com
dimityr.danailov[at]gmail.com
Slideshare.net
Github
YouTube
Founder at VarnaIT
Senior Developer at 158ltd.com
Topics Today
●
●
●
●
●
●
●
●

Overview
Architecture
Software
Java JDO support
Commands
Google API Explorer
CustomizeREST Interface
Tutorials
Sponsor
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
private
private
private
private
private
private
private
private
private

Long id ;
String beerName ;
String kindOfBeer ;
Long score ;
Long numberOfDrinks ;
Text image ;
String country ;
String description ;
Double latitude ;
Double longitude ;

public Long getId () {
return id ;
}
public void setId ( Long id ) {
this . id = id ;
}
// Getter and Setters
}
Java JDO support
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. JDO 1.0
was developed under the Java Community Process as JSR 12. JDO 2.0
was developed under JSR 243 and was released on May 10, 2006. JDO
2.1 was completed in Feb 2008, developed by the Apache JDO project.
JDO 2.2 was released in October 2008. JDO 3.0 was released in April
2010.
Java JDO support (2)
import
import
import
import
import

javax.jdo.annotations.IdGeneratorStrategy ;
javax.jdo.annotations.IdentityType ;
javax.jdo.annotations.PersistenceCapable ;
javax.jdo.annotations.Persistent ;
javax.jdo.annotations.PrimaryKey ;

@PersistenceCapable ( identityType = IdentityType. APPLICATION )
public class Beer {
@PrimaryKey
@Persistent ( valueStrategy = IdGeneratorStrategy. IDENTITY )
private Long id ;
@Api
@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.
Commands
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
Fix - Before
@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 - After
@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;
}
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
import
import
import
import

javax.jdo.annotations .IdGeneratorStrategy ;
javax.jdo.annotations .IdentityType ;
javax.jdo.annotations .PersistenceCapable ;
javax.jdo.annotations .Persistent ;
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);
// ...
}
Customize REST Interface (2)
@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) {
Search
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;
}
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 ***/
/*** 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
Senior Developer at 158ltd.com

Weitere ähnliche Inhalte

Was ist angesagt?

The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android JetpackAhmad Arif Faizin
 
Gradle and Android Studio : Best of Friends
Gradle and Android Studio : Best of FriendsGradle and Android Studio : Best of Friends
Gradle and Android Studio : Best of FriendsRomin Irani
 
Recap of Android Dev Summit 2018
Recap of Android Dev Summit 2018Recap of Android Dev Summit 2018
Recap of Android Dev Summit 2018Hassan Abid
 
Python with dot net and vs2010
Python with dot net and vs2010Python with dot net and vs2010
Python with dot net and vs2010Wei Sun
 
Visual studio 11 developer preview
Visual studio 11 developer previewVisual studio 11 developer preview
Visual studio 11 developer previewWei Sun
 
React Native - Getting Started
React Native - Getting StartedReact Native - Getting Started
React Native - Getting StartedTracy Lee
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_contentNAVEENSAGGAM1
 
Quality sdk for your apis in minutes!
Quality sdk for your apis in minutes!Quality sdk for your apis in minutes!
Quality sdk for your apis in minutes!Son Nguyen
 
Introduction to Firebase [Google I/O Extended Bangkok 2016]
Introduction to Firebase [Google I/O Extended Bangkok 2016]Introduction to Firebase [Google I/O Extended Bangkok 2016]
Introduction to Firebase [Google I/O Extended Bangkok 2016]Sittiphol Phanvilai
 
Exploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondExploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondKaushal Dhruw
 
Cloud Endpoints _Polymer_ Material design by Martin Görner
Cloud Endpoints_Polymer_Material design by Martin GörnerCloud Endpoints_Polymer_Material design by Martin Görner
Cloud Endpoints _Polymer_ Material design by Martin GörnerEuropean Innovation Academy
 
Angular App Presentation
Angular App PresentationAngular App Presentation
Angular App PresentationElizabeth Long
 
Intro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speedIntro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speedReid Baker
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2Dhyego Fernando
 
GDG Kuwait - Modern android development
GDG Kuwait - Modern android developmentGDG Kuwait - Modern android development
GDG Kuwait - Modern android developmentGDGKuwaitGoogleDevel
 
Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Ajinkya Saswade
 
Azure mobile apps
Azure mobile appsAzure mobile apps
Azure mobile appsDavid Giard
 
Rest api code completion for javascript - dotjs 2015
Rest api code completion for javascript - dotjs 2015Rest api code completion for javascript - dotjs 2015
Rest api code completion for javascript - dotjs 2015johannes_fiala
 

Was ist angesagt? (20)

The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android Jetpack
 
Gradle and Android Studio : Best of Friends
Gradle and Android Studio : Best of FriendsGradle and Android Studio : Best of Friends
Gradle and Android Studio : Best of Friends
 
Recap of Android Dev Summit 2018
Recap of Android Dev Summit 2018Recap of Android Dev Summit 2018
Recap of Android Dev Summit 2018
 
Android dev tips
Android dev tipsAndroid dev tips
Android dev tips
 
Python with dot net and vs2010
Python with dot net and vs2010Python with dot net and vs2010
Python with dot net and vs2010
 
Visual studio 11 developer preview
Visual studio 11 developer previewVisual studio 11 developer preview
Visual studio 11 developer preview
 
React Native - Getting Started
React Native - Getting StartedReact Native - Getting Started
React Native - Getting Started
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
 
Quality sdk for your apis in minutes!
Quality sdk for your apis in minutes!Quality sdk for your apis in minutes!
Quality sdk for your apis in minutes!
 
Google App Engine tutorial
Google App Engine tutorialGoogle App Engine tutorial
Google App Engine tutorial
 
Introduction to Firebase [Google I/O Extended Bangkok 2016]
Introduction to Firebase [Google I/O Extended Bangkok 2016]Introduction to Firebase [Google I/O Extended Bangkok 2016]
Introduction to Firebase [Google I/O Extended Bangkok 2016]
 
Exploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondExploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & Beyond
 
Cloud Endpoints _Polymer_ Material design by Martin Görner
Cloud Endpoints_Polymer_Material design by Martin GörnerCloud Endpoints_Polymer_Material design by Martin Görner
Cloud Endpoints _Polymer_ Material design by Martin Görner
 
Angular App Presentation
Angular App PresentationAngular App Presentation
Angular App Presentation
 
Intro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speedIntro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speed
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2
 
GDG Kuwait - Modern android development
GDG Kuwait - Modern android developmentGDG Kuwait - Modern android development
GDG Kuwait - Modern android development
 
Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI
 
Azure mobile apps
Azure mobile appsAzure mobile apps
Azure mobile apps
 
Rest api code completion for javascript - dotjs 2015
Rest api code completion for javascript - dotjs 2015Rest api code completion for javascript - dotjs 2015
Rest api code completion for javascript - dotjs 2015
 

Andere mochten auch

Cloud Conf Varna 2013 NoSQL Database - Mihail Velikov
Cloud Conf Varna 2013 NoSQL Database - Mihail VelikovCloud Conf Varna 2013 NoSQL Database - Mihail Velikov
Cloud Conf Varna 2013 NoSQL Database - Mihail VelikovМихаил Великов
 
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngineGoogle Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngineRoman Kirillov
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsRapidValue
 
VMworld Europe 2014: Preview the Latest Release from AirWatch
VMworld Europe 2014: Preview the Latest Release from AirWatchVMworld Europe 2014: Preview the Latest Release from AirWatch
VMworld Europe 2014: Preview the Latest Release from AirWatchVMworld
 
Enterprise Mobile Device Management (MDM)
Enterprise Mobile Device Management (MDM)Enterprise Mobile Device Management (MDM)
Enterprise Mobile Device Management (MDM)SPEC INDIA
 
MDM- Mobile Device Management
MDM- Mobile Device ManagementMDM- Mobile Device Management
MDM- Mobile Device ManagementBala G
 
Mobile device management presentation
Mobile device management presentationMobile device management presentation
Mobile device management presentationratneshsinghparihar
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architectureGabriele Falace
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS ArchitectureEyal Vardi
 

Andere mochten auch (11)

Cloud Conf Varna 2013 NoSQL Database - Mihail Velikov
Cloud Conf Varna 2013 NoSQL Database - Mihail VelikovCloud Conf Varna 2013 NoSQL Database - Mihail Velikov
Cloud Conf Varna 2013 NoSQL Database - Mihail Velikov
 
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngineGoogle Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
 
VMworld Europe 2014: Preview the Latest Release from AirWatch
VMworld Europe 2014: Preview the Latest Release from AirWatchVMworld Europe 2014: Preview the Latest Release from AirWatch
VMworld Europe 2014: Preview the Latest Release from AirWatch
 
Enterprise Mobile Device Management (MDM)
Enterprise Mobile Device Management (MDM)Enterprise Mobile Device Management (MDM)
Enterprise Mobile Device Management (MDM)
 
MDM- Mobile Device Management
MDM- Mobile Device ManagementMDM- Mobile Device Management
MDM- Mobile Device Management
 
Mobile device management presentation
Mobile device management presentationMobile device management presentation
Mobile device management presentation
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 

Ähnlich wie Google cloud endpoints

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 APIsTom Johnson
 
TDC2016SP - Trilha Android
TDC2016SP - Trilha AndroidTDC2016SP - Trilha Android
TDC2016SP - Trilha Androidtdc-globalcode
 
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015MobileMoxie
 
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Suzzicks
 
Making Things Work Together
Making Things Work TogetherMaking Things Work Together
Making Things Work TogetherSubbu Allamaraju
 
Prince st Tech Talk - MABI Framework
Prince st Tech Talk - MABI FrameworkPrince st Tech Talk - MABI Framework
Prince st Tech Talk - MABI FrameworkPhotis Patriotis
 
SP Rest API Documentation
SP Rest API DocumentationSP Rest API Documentation
SP Rest API DocumentationIT Industry
 
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIsExploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIswesley chun
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial IntroPamela Fox
 
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...Tom Johnson
 
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & morePower your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & morewesley chun
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code IgniterAmzad Hossain
 
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 PortalHimanshu Mendiratta
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Mario Cardinal
 
Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Maarten Mulders
 

Ähnlich wie Google cloud endpoints (20)

apiDoc Introduction
apiDoc IntroductionapiDoc Introduction
apiDoc Introduction
 
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
 
TDC2016SP - Trilha Android
TDC2016SP - Trilha AndroidTDC2016SP - Trilha Android
TDC2016SP - Trilha Android
 
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
 
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
 
Making Things Work Together
Making Things Work TogetherMaking Things Work Together
Making Things Work Together
 
Cgi
CgiCgi
Cgi
 
Prince st Tech Talk - MABI Framework
Prince st Tech Talk - MABI FrameworkPrince st Tech Talk - MABI Framework
Prince st Tech Talk - MABI Framework
 
Prince sttalkv5
Prince sttalkv5Prince sttalkv5
Prince sttalkv5
 
SP Rest API Documentation
SP Rest API DocumentationSP Rest API Documentation
SP Rest API Documentation
 
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIsExploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
 
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
 
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & morePower your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
Copy of cgi
Copy of cgiCopy of cgi
Copy of cgi
 
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
 
Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
 
Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)
 

Mehr von Dimitar Danailov

Evolution - ReConnect() 2019
Evolution - ReConnect() 2019Evolution - ReConnect() 2019
Evolution - ReConnect() 2019Dimitar Danailov
 
Data Visualization and D3Js
Data Visualization and D3JsData Visualization and D3Js
Data Visualization and D3JsDimitar 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
 
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 functionsDimitar 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 PolymerDimitar Danailov
 
Typescript - MentorMate Academy
Typescript - MentorMate AcademyTypescript - MentorMate Academy
Typescript - MentorMate AcademyDimitar Danailov
 
HackConf2016 - Ruby on Rails: Unexpected journey
HackConf2016 - Ruby on Rails: Unexpected journeyHackConf2016 - Ruby on Rails: Unexpected journey
HackConf2016 - Ruby on Rails: Unexpected journeyDimitar Danailov
 
Microservices - Code Voyagers Sofia
Microservices - Code Voyagers SofiaMicroservices - Code Voyagers Sofia
Microservices - Code Voyagers SofiaDimitar Danailov
 
Mongo DB Terms - Mentormate Academy
Mongo DB Terms - Mentormate AcademyMongo DB Terms - Mentormate Academy
Mongo DB Terms - Mentormate AcademyDimitar 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 VarnaDimitar Danailov
 
MicroServices: Advantages ans Disadvantages
MicroServices: Advantages ans DisadvantagesMicroServices: Advantages ans Disadvantages
MicroServices: Advantages ans DisadvantagesDimitar Danailov
 
Softuni.bg - Microservices
Softuni.bg - MicroservicesSoftuni.bg - Microservices
Softuni.bg - MicroservicesDimitar Danailov
 
Cloud Conf Varna: Vagrant and Amazon
Cloud Conf Varna: Vagrant and AmazonCloud Conf Varna: Vagrant and Amazon
Cloud Conf Varna: Vagrant and AmazonDimitar Danailov
 
HackConf2015 - Ruby on Rails: Unexpected journey
HackConf2015 - Ruby on Rails: Unexpected journeyHackConf2015 - Ruby on Rails: Unexpected journey
HackConf2015 - Ruby on Rails: Unexpected journeyDimitar Danailov
 

Mehr von 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
 

Kürzlich hochgeladen

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Kürzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Google cloud endpoints

  • 2. Google Clound Endpoints Dimitar Danailov Senior Developer at 158ltd.com dimityr.danailov[at]gmail.com Slideshare.net Github YouTube Founder at VarnaIT Senior Developer at 158ltd.com
  • 3. Topics Today ● ● ● ● ● ● ● ● Overview Architecture Software Java JDO support Commands Google API Explorer CustomizeREST Interface Tutorials
  • 5.
  • 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 private private private private private private private private private Long id ; String beerName ; String kindOfBeer ; Long score ; Long numberOfDrinks ; Text image ; String country ; String description ; Double latitude ; Double longitude ; public Long getId () { return id ; } public void setId ( Long id ) { this . id = id ; } // Getter and Setters }
  • 15. Java JDO support 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. JDO 1.0 was developed under the Java Community Process as JSR 12. JDO 2.0 was developed under JSR 243 and was released on May 10, 2006. JDO 2.1 was completed in Feb 2008, developed by the Apache JDO project. JDO 2.2 was released in October 2008. JDO 3.0 was released in April 2010.
  • 16. Java JDO support (2) import import import import import javax.jdo.annotations.IdGeneratorStrategy ; javax.jdo.annotations.IdentityType ; javax.jdo.annotations.PersistenceCapable ; javax.jdo.annotations.Persistent ; javax.jdo.annotations.PrimaryKey ; @PersistenceCapable ( identityType = IdentityType. APPLICATION ) public class Beer { @PrimaryKey @Persistent ( valueStrategy = IdGeneratorStrategy. IDENTITY ) private Long id ;
  • 17.
  • 18. @Api @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.
  • 19. Commands 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
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. Fix - Before @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; }
  • 26. Fix - After @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; }
  • 29.
  • 31. import com.google.appengine.api.users.User; import import import import import javax.jdo.annotations .IdGeneratorStrategy ; javax.jdo.annotations .IdentityType ; javax.jdo.annotations .PersistenceCapable ; javax.jdo.annotations .Persistent ; 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. Customize REST Interface (2) @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) {
  • 35.
  • 36.
  • 37. Search 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; }
  • 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 ***/ /*** Latitude ***/ Double beerLatitude = beer.getLatitude (); Double docBulderLatitude = (double) 0; if (beerLatitude != null) { docBulderLatitude = beerLatitude ; } docBuilder .addField(Field.newBuilder ().setName("latitude" ).setNumber (docBulderLatitude )); /*** Latitude ***/
  • 40. /*** 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); }
  • 41. 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; }
  • 42.
  • 43.
  • 44. 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. Questions ? Dimitar Danailov Senior Developer at 158ltd.com dimityr.danailov[at]gmail.com Slideshare.net Github YouTube Founder at VarnaIT Senior Developer at 158ltd.com