Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building An AEM API Clients Ecosystem

1,617 views

Published on

Delivered at Adobe Marketing Cloud – Community Expo (AMCCE).
https://www.meetup.com/Melbourne-Adobe-Experience-Cloud/events/233363101/?eventId=233363101

Published in: Technology
  • Be the first to comment

Building An AEM API Clients Ecosystem

  1. 1. BUILDING AN AEM API CLIENTS ECOSYSTEM Cliffano Subagio - Michael Diender - Stephen Shim Shine Solutions
  2. 2. Agenda • A little bit of history • API clients ecosystem • Demo applications • To do list
  3. 3. AEM 5.6.1
  4. 4. Q: How do you deploy a package? A: Use this curl command. Q: Really? Q: How do you …? A: Use that curl command.
  5. 5. 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
  6. 6. API client • A helper library • Authentication • HTTP request/response • Debugging
  7. 7. Why API client? • First class for your tech stack • Better error handling • Simpler response body parsing • Easier integration with 3rd party tools
  8. 8. Moarrr clients • In 2014: wrote an AEM Python client • In 2015: wrote an AEM Ruby client • Other clients written by others
  9. 9. There’s got to be
 a better way
  10. 10. Swagger • An API framework • Open API specification • Swagger Codegen
  11. 11. API client ecosystem • More than a single client • Centred on Open API specification • Generate all API clients
  12. 12. API SPECIFICATION GENERATED RUBY CLIENT GENERATED PYTHON CLIENT GENERATED JAVASCRIPT CLIENT GENERATED JAVA CLIENT RUBY_AEM PYTHONAEM? NODE-AEM? AEMAPI4J? Swagger AEM
  13. 13. API specification paths: /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
  14. 14. 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
  15. 15. 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
  16. 16. RUBY CLIENT DEMO
  17. 17. AEM Integration with Slack
  18. 18. PYTHON CLIENT DEMO
  19. 19. AEM Integration with AWS Lambda
  20. 20. SWAGGER AEM RUBY CLIENT PYTHON CLIENT JAVASCRIPT CLIENT JAVA CLIENT JAVA FRAMEWORKS An ecosystem ANSIBLE PUPPET AWS LAMBDA CHEF SLACK GULP GRUNT GOOGLE HOME AMAZON ECHO APPLE WATCH
  21. 21. TODO • Python, JavaScript, and Java clients
 (in progress) • More languages support?
  22. 22. TODO • AEM 6.1 Assets API • 100% generated clients
  23. 23. Join the effort, contributions are welcome! https://github.com/shinesolutions/swagger-aem
  24. 24. 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

×