From 0a053f08a494f0dc04bcb8b8b0c64affa85a0650 Mon Sep 17 00:00:00 2001 From: Noccy Date: Sat, 11 Dec 2021 01:07:06 +0000 Subject: [PATCH] Update 'com.noccy.apiclient' --- com.noccy.apiclient.md | 74 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/com.noccy.apiclient.md b/com.noccy.apiclient.md index 176d075..510d22a 100644 --- a/com.noccy.apiclient.md +++ b/com.noccy.apiclient.md @@ -1 +1,73 @@ -# ApiClient Plugin \ No newline at end of file +# ApiClient Plugin + + +## Creating catalogs and requests + +``` +$ spark api:catalog --create myapp baseurl=http://127.0.0.1/app/ info="MyApp API" +$ spark api:request --save myapp.ping url=v2/ping info="Ping the server" http.header.X-Special=magic +``` + +Requests are performed with the `api:request` command: + +``` +$ spark api:request myapp.ping +``` + +## 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 +# What protocol to use +protocol={"http"|"websocket"|"xmlrpc"|"jsonrpc"} +# Final URL is [urlbase+]url +urlbase={url} +url={url} + +## Authentication options +# Username and password, for basic authentication +auth.username={username} +auth.password={password} +# Token, for bearer authentication +auth.token={token} +# If there is ever a need to be explicit +auth.type={"auto"|"basic"|"bearer"} + +## HTTP options +# HTTP request method +http.method={"GET"|"POST"|...} +# HTTP request version +http.version={"1.0"|"1.1"|"2.0"} +# HTTP request header +http.header.{name}={value} +# HTTP query string field +http.query.{field}={value} +# HTTP POST body +http.body={raw-body} +# HTTP POST body as json or object +http.body.json={object} + +## RPC options +# The method to invoke for XmlRpc and JsonRpc +rpc.method={string} +# Set argument by index or name +rpc.argument.{index}={value} + +## Request handling +# Follow HTTP redirects? +request.follow-redirects={"auto"|"no"|"yes"} +# Max number of redirects to follw +request.max-redirects={number} + +## Response handling +# Parse the response, for readability +response.parse={"none"|"json"|"yaml"|"xml"} +# Response codes that are considered good +response.good="200,201,202,203,204,205,206,207,208" +```