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

Building An AEM API Clients Ecosystem

Embed Size (px)

Citation preview

BUILDING AN AEM API CLIENTS ECOSYSTEM

Cliffano Subagio - Michael Diender - Stephen Shim Shine Solutions

Agenda

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

AEM 5.6.1

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

API client

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

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

There’s got to bea better way

Swagger

• An API framework • Open API specification • Swagger Codegen

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

RUBY CLIENT DEMO

AEM Integration with Slack

PYTHON CLIENT DEMO

AEM Integration with AWS Lambda

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

TODO

• Python, JavaScript, and Java clients

(in progress) • More languages support?

TODO

• AEM 6.1 Assets API • 100% generated clients

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