php-spark/plugins/com.noccy.apiclient
Chris 9050c74a08 Plugin fixes
* Added vertical rendering to com.noccy.pdo.shell
* Added missing Log classes for com.noccy.apiclient
2021-12-22 03:03:16 +01:00
..
Api Multiple fixes 2021-12-11 01:44:01 +01:00
Commands Misc fixes 2021-12-17 12:51:29 +01:00
Log Plugin fixes 2021-12-22 03:03:16 +01:00
Request Multiple fixes 2021-12-11 01:44:01 +01:00
README.md Multiple fixes 2021-12-11 01:44:01 +01:00
sparkplug.php Misc fixes 2021-12-17 12:51:29 +01:00

README.md

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"