Skip to content
Snippets Groups Projects

v0.9 update docs

Merged Hahn Axel (hahn) requested to merge extend-authorization into master
9 files
+ 736
29
Compare changes
  • Side-by-side
  • Inline

Files

## rest-api-client.sh
List of all functions in alphabetic order
### http()
[line: 94](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L94)
### http.addHeader()
```txt
Add a line to the request header
🟩 param string line to add, eg "Connection: keep-alive"
```
[line: 680](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L680)
### http.dump()
```txt
Dump information about request and response
no params
```
[line: 575](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L575)
### http.flushCache()
```txt
Flush the cache
no params
```
[line: 840](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L840)
### http.getRequestAge()
```txt
Get age of the response in sec.
It is especially useful after responseImport
no param
returns integer age of the response in sec
```
[line: 422](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L422)
### http.getRequestTs()
```txt
Get timestamp of the response as a Unix timestamp.
no param
returns string the timestamp of the response
```
[line: 408](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L408)
### http.getResponse()
```txt
Get response body
no param
returns string the response body
```
[line: 441](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L441)
### http.getResponseData()
```txt
Get curl data of this request with status, transferred bytes, speed, ...
no param
returns string the response data
```
[line: 454](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L454)
### http.getResponseHeader()
```txt
Get response header
no param
returns string the response header
```
[line: 467](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L467)
### http.getResponseRaw()
```txt
Get raw response (not available after import)
no params
no param
```
[line: 480](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L480)
### http.getStatus()
```txt
Get Http status as string OK|Redirect|Error
no params
```
[line: 491](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L491)
### http.getStatuscode()
```txt
Get Http status code of the request as 3 digit number
no params
```
[line: 504](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L504)
### http.help()
```txt
show a help text
no params
```
[line: 851](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L851)
### http.init()
```txt
Initialize the client
Initialize the client for a new request. Call this before any other
function. It will reset all variables.
```
[line: 115](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L115)
### http.isClientError()
```txt
Was the repsonse a client error (4xx)
no params
```
[line: 553](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L553)
### http.isError()
```txt
Was the repsonse a client error (4xx or 5xx)
no params
```
[line: 542](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L542)
### http.isOk()
```txt
Check: was response a 2xx status code?
output is a statuscode if it matches ... or empty
Additionally you can verify the return code
$? -eq 0 means YES
$? -ne 0 means NO
no params
```
[line: 520](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L520)
### http.isRedirect()
```txt
Was the repsonse a redirect?
no params
```
[line: 531](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L531)
### http.isServerError()
```txt
Was the repsonse a client error (5xx)
no params
```
[line: 564](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L564)
### http.loadcfg()
```txt
Load a config file
This function is marked as deprecated.
It will be removed in the future.
🟩 param string config file name
Sourcing that file will set the following vars
- RestApiUser
- RestApiPassword
- RestApiBaseUrl
- RestApiDocs
The function will then set the "internal" vars
- http_req__auth
- http_req__fullurl
- http_req__docs
```
[line: 283](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L283)
### http.makeRequest()
```txt
Execute the request
🔹 param string optional: method; GET|POST|PUT|DELETE|...
🔹 param string optional: full url
🔹 param string optional: request body
description:
This function does the following:
1. Check if to use a cache
2. If not cached, make the request
3. If cached, use the cached result
```
[line: 167](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L167)
### http.quit()
```txt
Show error message with last return code and quit with this exitcode
This function is used to quit the script with a meaningful error message
and the exit code of the last command.
The message is printed to STDERR and contains the return code.
If a documentation URL is known, it is printed as a hint.
The exit code is the one of the last command.
To prevent the script from exiting when this function is called from a
sourced file, the exit is commented out.
no params
```
[line: 250](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L250)
### http.responseDelete()
```txt
Delete an exported file; this is especially useful if you use
AUTOFILE functionality
🟩 param string filename with stored response
```
[line: 651](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L651)
### http.responseExport()
```txt
Export response to a file
🔹 param string optional: custom filename
```
[line: 609](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L609)
### http.responseImport()
```txt
Import a former response from a file
🟩 param string filename with stored response
```
[line: 627](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L627)
### http.setAccept()
```txt
set Accept request header and override default
🟩 param string accept header value, eg text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
```
[line: 691](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L691)
### http.setAuth()
```txt
Set basic authentication
Without given parameter, authentication is removed
🔹 param string optional: USER:PASSWORD
```
[line: 707](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L707)
### http.setAuthorization()
```txt
Set authentication via Athorization header
Without given parameter, authorization is removed
🔹 param string optional: type, eg. Basic|Bearer|Negotiate
🔹 param string optional: token or encoded user + password
```
[line: 724](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L724)
### http.setBaseUrl()
```txt
Set a base url of an API
Remark: Then use http.setUrl to complet the url to request
🟩 param string url
```
[line: 751](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L751)
### http.setBody()
```txt
Set body to send for PUTs and POSTs
🟩 param string body
```
[line: 739](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L739)
### http.setCacheFile()
```txt
Set cache file
🟩 param string filename
```
[line: 829](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L829)
### http.setCacheTtl()
```txt
Set cache ttl in seconds
🟩 param integer ttl in seconds
```
[line: 818](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L818)
### http.setDebug()
```txt
Enable or disable debug mode
🟩 param integer 0|1
```
[line: 763](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L763)
### http.setDocs()
[line: 767](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L767)
### http.setFullUrl()
```txt
Set a full url to request
🔹 param string optional: url
```
[line: 789](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L789)
### http.setMethod()
```txt
Set the method to use; GET|POST|PUT|DELETE|...
🟩 param string name of method
```
[line: 778](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L778)
### http.setUrl()
```txt
Complete the base url
🟩 param string url part behind base url
```
[line: 804](https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client/-/blob/master/rest-api-client.sh#L804)
Loading