Wednesday, September 10, 2014

WSO2 API Manager - Basic user operations curl command( How to do basic operations using curl commands)

Here in this post i will list out curl commands that required to cover complete API Manager (basic) use case. Here we will do fallowing operations. Here we need to login API Manager publisher and store multiple times. Here user will be tenant user(ttt@ttt.ttt). if need change any parameter.

1) Create APIs
2) Publish APIs
3) Create application
4) Subscribe to APIs for that application
5) Remove subscriptions
6) Remove application
7) Remove APIs

API Publisher
=============
curl -X POST -c cookies http://localhost:9763/publisher/site/blocks/user/login/ajax/login.jag -d 'action=login&username=ttt@ttt.ttt&password=tttttt'

1) Create APIs
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=addAPI&name=sanjeewa-api&context=/sanjeewa-api&version=1.0.0&tier=Bronze&tier=Gold&transports=http&http_checked=http&transports=https&https_checked=https&description=sanjeewa-api&visibility=public API&tags=sanjeewa-api,api&resourceCount=0&resourceMethod-0=GET,PUT,POST,DELETE,OPTIONS&resourceMethodAuthType-0=Application & Application User,Application & Application User,Application & Application User,Application & Application User,None&uriTemplate-0=/*&resourceMethodThrottlingTier-0=Unlimited, Unlimited, Unlimited, Unlimited, Unlimited&tiersCollection=Bronze,Gold,Silver,Unlimited" -d 'endpoint_config={"production_endpoints":{"url":"http://search.twitter.com","config":null},"endpoint_type":"http"}'

2) Publish APIs
curl -X POST -b cookies 'http://localhost:9763/publisher/site/blocks/life-cycles/ajax/life-cycles.jag' -d 'action=updateStatus&name=sanjeewa-api&version=1.0.0&provider=ttt@ttt.ttt&status=PUBLISHED&publishToGateway=true&requireResubscription=true'

API Store
=========
curl -X POST -c cookies http://localhost:9763/store/site/blocks/user/login/ajax/login.jag -d 'action=login&username=ttt@ttt.ttt&password=tttttt'

3) Create application
curl -X POST -b cookies http://localhost:9763/store/site/blocks/application/application-add/ajax/application-add.jag -d 'action=addApplication&application=sanjeewa-application&tier=unlimited&description=&callbackUrl='

4) Subscribe to APIs for that application
curl -b cookies http://localhost:9763/store/site/blocks/application/application-list/ajax/application-list.jag?action=getApplications
Got app id for sanjeewa-application each time and used it for further calls.

curl -X POST -b cookies http://localhost:9763/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag -d 'action=addSubscription&name=sanjeewa-api&version=1.0.0&provider=ttt@ttt.ttt&tier=Unlimited&applicationId=7'

5) Remove subscriptions
curl -X POST -b cookies http://localhost:9763/store/site/blocks/subscription/subscription-remove/ajax/subscription-remove.jag -d 'action=removeSubscription&name=sanjeewa-api&version=1.0.0&provider=ttt@ttt.ttt&applicationId=7'

6) Remove application
curl -X POST -b cookies http://localhost:9763/store/site/blocks/application/application-remove/ajax/application-remove.jag -d "action=removeApplication&application=sanjeewa-application"

API Publisher
=============
curl -X POST -c cookies http://localhost:9763/publisher/site/blocks/user/login/ajax/login.jag -d 'action=login&username=ttt@ttt.ttt&password=tttttt'
7) Remove APIs
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/remove.jag -d "action=removeAPI&name=sanjeewa-api&version=1.0.0&provider=ttt@ttt.ttt"

No comments:

Post a Comment