Upload
cliffano-subagio
View
510
Download
0
Embed Size (px)
Citation preview
BUILDING AN AEM API CLIENTS ECOSYSTEM
Cliffano Subagio - Michael Diender - Stephen Shim Shine Solutions
Q: How do you deploy a package?A: Use this curl command.
Q: Really?
Q: How do you …?A: Use that curl command.
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
Why API client?
• First class for your tech stack • Better error handling • Simpler response body parsing • Easier integration with 3rd party tools
Moarrr clients
• In 2014: wrote an AEM Python client • In 2015: wrote an AEM Ruby client • Other clients written by others
API client ecosystem
• More than a single client • Centred on Open API specification • Generate all API clients
API SPECIFICATION
GENERATED RUBY CLIENT
GENERATED PYTHON CLIENT
GENERATED JAVASCRIPT
CLIENT
GENERATED JAVA CLIENT
RUBY_AEM
PYTHONAEM?
NODE-AEM?
AEMAPI4J?
Swagger AEM
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
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
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
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
Join the effort, contributions are welcome!https://github.com/shinesolutions/swagger-aem
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