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.

Use build service API in your program


Published on

SUSE Labs Taipei Technology Sharing Day 2016

Published in: Software
  • Be the first to comment

  • Be the first to like this

Use build service API in your program

  1. 1. Use build service API in your program Max Lin – Software Engineer
  2. 2. 2 What is build service api? • RESTful API of Open Build Service • • open-build-service/docs/api/api/api.txt • open-build-service/src/api/config/routes.rb • Client side usage: ‒ osc : Command Line Interface to work with Open Build Service ‒ osc api /route + arguments
  3. 3. 3 Benefits • `osc command` is wrapped ‒ see in osc • `osc api` is returned the xml data • Not that easily to do post-processing from the output of osc command • The usage does not provided by osc command
  4. 4. 4 `osc command` example
  5. 5. 5 `osc api` example
  6. 6. 6 `osc api` example(cont.) • # osc api -X POST -d "hello 2016" /comments/project/home:mlin7442 • Returned: ‒ <status code="ok"> ‒ <summary>Ok</summary> ‒ </status>
  7. 7. 7 For Perl • Wrapped your http request(eg. HTTP::Request) and send it to right place and grab the return data • Call `osc api` in system(), open() • Cares of authentication part or using public api route instead
  8. 8. 8 For Python • Wrapped your http request(eg. httplib) and sent by urlopen() ‒ Make sure go with authorisation header or go with public api route then. • Easy way: use existing osc python api ‒ import osc.core ‒ import osc.conf ‒ http_{GET, PUT, POST, DELETE} available ‒ Some existing functions, do not need to re-do the wheel! ‒ makeurl() help you to get the specific result if no existing function can adopt your requirement
  9. 9. 9 Real case • Changelog Checker - • Goal ‒ Make sure it has valid tag within submission, eg. bsc#, fate#, if not, decline then. ‒ Accept the the submission had same revision was submitted to openSUSE Factory or merged already. ‒ Accept new package submissions ‒ Accept delete request and add_role request
  10. 10. Questions?
  11. 11. Thank you. Join the conversation, contribute & have a lot of fun!
  12. 12. 12 Have a Lot of Fun, and Join Us At:
  13. 13. General Disclaimer This document is not to be construed as a promise by any participating organisation to develop, deliver, or market a product. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. openSUSE makes no representations or warranties with respect to the contents of this document, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. The development, release, and timing of features or functionality described for openSUSE products remains at the sole discretion of openSUSE. Further, openSUSE reserves the right to revise this document and to make changes to its content, at any time, without obligation to notify any person or entity of such revisions or changes. All openSUSE marks referenced in this presentation are trademarks or registered trademarks of SUSE LLC, in the United States and other countries. All third-party trademarks are the property of their respective owners. License This slide deck is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license. It can be shared and adapted for any purpose (even commercially) as long as Attribution is given and any derivative work is distributed under the same license. Details can be found at Credits Template Richard Brown Design & Inspiration openSUSE Design Team guidelines/