Top Banner
BUILDING AN AEM API CLIENTS ECOSYSTEM Cliffano Subagio - Michael Diender - Stephen Shim Shine Solutions
26

Building An AEM API Clients Ecosystem

Apr 16, 2017

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building An AEM API Clients Ecosystem

BUILDING AN AEM API CLIENTS ECOSYSTEM

Cliffano Subagio - Michael Diender - Stephen Shim Shine Solutions

Page 2: Building An AEM API Clients Ecosystem

Agenda

• A little bit of history • API clients ecosystem • Demo applications • To do list

Page 3: Building An AEM API Clients Ecosystem

AEM 5.6.1

Page 4: Building An AEM API Clients Ecosystem

Q: How do you deploy a package?A: Use this curl command.

Q: Really?

Q: How do you …?A: Use that curl command.

Page 5: Building An AEM API Clients Ecosystem
Page 6: Building An AEM API Clients Ecosystem
Page 7: Building An AEM API Clients Ecosystem

Problems

• curl —fail is not fail-safe • Can’t rely on exit code • Can’t rely on HTTP status code • Need to parse response body • Unexpected AEM state

Page 8: Building An AEM API Clients Ecosystem

API client

• A helper library • Authentication • HTTP request/response • Debugging

Page 9: Building An AEM API Clients Ecosystem

Why API client?

• First class for your tech stack • Better error handling • Simpler response body parsing • Easier integration with 3rd party tools

Page 10: Building An AEM API Clients Ecosystem

Moarrr clients

• In 2014: wrote an AEM Python client • In 2015: wrote an AEM Ruby client • Other clients written by others

Page 11: Building An AEM API Clients Ecosystem

There’s got to bea better way

Page 12: Building An AEM API Clients Ecosystem

Swagger

• An API framework • Open API specification • Swagger Codegen

Page 13: Building An AEM API Clients Ecosystem

API client ecosystem

• More than a single client • Centred on Open API specification • Generate all API clients

Page 14: Building An AEM API Clients Ecosystem

API SPECIFICATION

GENERATED RUBY CLIENT

GENERATED PYTHON CLIENT

GENERATED JAVASCRIPT

CLIENT

GENERATED JAVA CLIENT

RUBY_AEM

PYTHONAEM?

NODE-AEM?

AEMAPI4J?

Swagger AEM

Page 15: Building An AEM API Clients Ecosystem

API specificationpaths: /libs/granite/security/post/authorizables: post: operationId: postAuthorizables produces: - text/html parameters: - name: authorizableId in: query required: true type: string … responses: default: schema: type: string

Page 16: Building An AEM API Clients Ecosystem

require 'swagger_aem'

SwaggerAemClient.configure { |conf| [ conf.host = 'http://localhost:4502', conf.username = 'admin', conf.password = 'admin', conf.params_encoding = :multi ]} api = SwaggerAemClient::SlingApi.new data, status_code, headers = api.post_authorizables_with_http_info( authorizable_id = 'someuser', intermediate_path = '/home/users/s', { :create_user => '', :reppassword => 'somepassword' } )

Ruby client

Page 17: Building An AEM API Clients Ecosystem

import swaggeraem import swaggeraem.configuration

swaggeraem.configuration.username = 'admin' swaggeraem.configuration.password = 'admin' client = swaggeraem.ApiClient(‘http://localhost:4502/') api = swaggeraem.apis.SlingApi(client)

opts= { 'create_user': '', 'reppassword': 'somepassword' } response = api.post_authorizables_with_http_info( user_name, '/home/users/s', **opts)

Python client

Page 18: Building An AEM API Clients Ecosystem

RUBY CLIENT DEMO

Page 19: Building An AEM API Clients Ecosystem

AEM Integration with Slack

Page 20: Building An AEM API Clients Ecosystem

PYTHON CLIENT DEMO

Page 21: Building An AEM API Clients Ecosystem

AEM Integration with AWS Lambda

Page 22: Building An AEM API Clients Ecosystem

SWAGGER AEM

RUBY CLIENTPYTHON CLIENT

JAVASCRIPT CLIENT

JAVA CLIENT

JAVA FRAMEWORKS

An ecosystem

ANSIBLE

PUPPET

AWS LAMBDA

CHEF

SLACK

GULP

GRUNT

GOOGLE HOME

AMAZON ECHO

APPLE WATCH

Page 23: Building An AEM API Clients Ecosystem

TODO

• Python, JavaScript, and Java clients

(in progress) • More languages support?

Page 24: Building An AEM API Clients Ecosystem

TODO

• AEM 6.1 Assets API • 100% generated clients

Page 25: Building An AEM API Clients Ecosystem

Join the effort, contributions are welcome!https://github.com/shinesolutions/swagger-aem

Page 26: Building An AEM API Clients Ecosystem

CREDITS

Background images are from Google search with reuse rights:

• Europasaurus holgeri - https://en.wikipedia.org/wiki/Mesozoic#/media/File:Europasaurus_holgeri_Scene_2.jpg

• Yes really - http://www.quickmeme.com/meme/36i4mo

• Head of the Charles Regatta - http://hocr.tumblr.com/post/34706902195