stratos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Udara Liyanage <ud...@wso2.com>
Subject Python based CLI for Stratos
Date Tue, 02 Sep 2014 09:41:23 GMT
Hi,

I thought of implementing $subject as a project to learn Python. I tried
below code to list deployment policies as a test and it works well. I have
not implemented this as a CLI yet.

Advantages,

   - JAVA not required.
   - Seems Python requires less coding than Java since there are built in
   support for http calls
   - Linux and Mac has built in Python support

Any suggestions ?


   1. import requests
   2. import json
   3. from tabulate import tabulate
   4.
   5. url = 'https://localhost:9443/stratos/admin/policy/deployment'
   6. response = requests.get(url, auth=('admin', 'admin'), verify=False)
   7. dep_policies = json.loads(response.text)
   8.
   9. table = []
   10. for p in dep_policies['deploymentPolicy']:
   11.     id = p['id']
   12.     row = [id]
   13.     table.append(row)
   14.
   15. headers = ["Id"]
   16. print tabulate(table, headers)


-- 

Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

web: http://udaraliyanage.wordpress.com
phone: +94 71 443 6897

Mime
View raw message