# ApiClient for Spark ## Installation To install, downlad and extract the plugin directory into your plugin directory. ## Usage *Note: Profiles are not yet implemented* You should make a catalog and a profile first. You don't have to, but this will save you some time. $ spark api:catalog --create mysite \ protocol=http \ urlbase=http://127.0.0.1:80/api/ $ spark api:profile --create apiuser \ --catalog mysite \ auth.username=apiuser \ auth.token=APITOKEN You can now add some requests: $ spark api:request --add mysite.info \ url=v1/info \ http.method=POST \ response.parse=json And send them: $ spark api:request -p apiuser mysite.info ## Internals ApiClient works on a map of properties, populated with the defaults from the catalog. The request properties are then appied, followed by the profile properties. ### Properties ``` # Core properties protocol={"http"|"websocket"|"xmlrpc"|"jsonrpc"} # Final URL is [urlbase+]url urlbase={url} url={url} # Authentication options auth.username={username} auth.password={password} auth.token={token} auth.type={"basic"|"bearer"} # HTTP options http.method={"GET"|"POST"|...} http.version={"1.0"|"1.1"|"2.0"} http.header.{name}={value} http.query.{field}={value} http.body={raw-body} http.body.json={object} # RPC options rpc.method={string} rpc.argument.{index}={value} # Request handling request.follow-redirecs={"auto"|"no"|"yes"} request.max-redirects={number} # Response handling response.parse={"none"|"json"|"yaml"|"xml"} response.good="200,201,202,203,204,205,206,207,208" ```