Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-passive-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source
icinga-passive-client
Commits
27d53bd7
Commit
27d53bd7
authored
7 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update reat-api-client
parent
5224f6e5
No related branches found
No related tags found
1 merge request
!44
OP#7546 Icinga Check für ablaufende Gitlab tokens https://projects.iml.unibe.ch/work_packages/7546
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inc/rest-api-client.sh
+24
-21
24 additions, 21 deletions
inc/rest-api-client.sh
with
24 additions
and
21 deletions
inc/rest-api-client.sh
+
24
−
21
View file @
27d53bd7
...
...
@@ -22,9 +22,10 @@
# 2022-01-11 v0.7 axel.hahn@iml.unibe.ch fixes using shellcheck
# 2024-10-09 v0.8 axel.hahn@unibe.ch add setAuthorization; customize accept header, add custom request headers
# 2024-10-10 v0.9 axel.hahn@unibe.ch update docs
# 2024-10-23 v0.10 axel.hahn@unibe.ch update help
# ======================================================================
http_cfg__about
=
"Bash REST API client v0.
9
"
http_cfg__about
=
"Bash REST API client v0.
10
"
typeset
-i
http_cfg__debug
=
0
typeset
-i
http_cfg__cacheTtl
=
0
http_cfg__cacheDir
=
/var/tmp/http-cache
...
...
@@ -867,7 +868,7 @@ INSTRUCTION:
- Then you can run functions starting with "http."
http.init
Start a new request. It resets internal vars of the last re
sponse
Start a new request. It resets internal vars of the last re
quest
(if there was one).
http.setDebug 0|1
...
...
@@ -876,52 +877,54 @@ INSTRUCTION:
- initialize a request
setAccept ACCEPT
setAccept
"<
ACCEPT
HEADER>"
Set authentication with user and password for basic auth
Default:
$http_req__accept
setAuth
AUTH:
PASSWORD
setAuth
"<USER>:<
PASSWORD
>"
Set authentication with user and password for basic auth
Without given parameter, authentication is removed
setAuthorization TYPE
TOKEN|HASH
setAuthorization
"<
TYPE
>" "<
TOKEN|HASH
>"
Set authentication with Authorization header.
As TYPE you can use Basic|Bearer|Negotiate|...
2nd param is the token or hased user+password
2nd param is the token or has
h
ed user+password
Without given parameter, authorization is removed
http.setBody DATA
http.setBody
"<
DATA
>"
set a body for POST/ PUT requests.
http.setBaseUrl URL
http.setBaseUrl
"<
URL
>"
Set a base url to an api.
renmark:
Use http.setUrl to built a complete url.
http.setDocs URL
http.setDocs "<URL>"
Set a docs url. If set it will be shown as additional hint when a
request fails.
http.setMethod METHOD
http.setMethod
"<
METHOD
>"
Set a http method. Use an uppercase string for GET|POST|PUT|DELETE|...
http.setFullUrl URL
http.setFullUrl
"<
URL
>"
Set a complete url for a request.
http.setUrl REQUEST?QUERY
http.setUrl
"<
REQUEST?QUERY
>"
Set a relative url for a request.
This requires to use http.setBaseUrl before.
http.addHeader HEADER_LINE
http.addHeader
"<
HEADER_LINE
>"
Add a header line to the request.
This command can be repeated multiple times.
- caching functions
http.setCacheTtl SECONDS
http.setCacheTtl
<
SECONDS
>
Enable caching with values > 0
Remark: only GET requests will be cached.
Default: 0 (no caching)
http.setCacheFile FILENAME
http.setCacheFile
"<
FILENAME
>"
Set a file where to read/ store a request
Default: empty; autogenerated file below
$http_cfg__cacheDir
...
...
@@ -930,10 +933,10 @@ INSTRUCTION:
- make the request
http.makeRequest [[METHOD] [URL] [BODY]]
The parameters are optional. Without parameter the rquest will be
http.makeRequest [[
<
METHOD
>
] [
"<
URL
>"
] [
"<
BODY
>"
]]
The parameters are optional. Without parameter the r
e
quest will be
started with given data in http.set* functions described above.
If minimum one pram is given then they are handled:
If minimum one p
a
ram is given then they are handled:
METHOD optional: set a method (must be uppercase) - see http.setMethod
URL set a relative url - see http.setUrl
BODY optional: set a body - see http.setBody
...
...
@@ -987,7 +990,7 @@ INSTRUCTION:
- import/ export
http.responseExport [FILE]
http.responseExport [
"<
FILE
>"
]
dump the response data
Without parameter it is written on STDOUT.
You can set a filename to write it to a file.
...
...
@@ -998,7 +1001,7 @@ INSTRUCTION:
http.makeRequest "https://example.com/api/"
http.responseExport /tmp/something_AUTOFILE_.txt
http.responseImport FILE
http.responseImport
"<
FILE
>"
Import an export file.
To use the AUTOFILE mechanism from export set
the url first.
...
...
@@ -1006,7 +1009,7 @@ INSTRUCTION:
http.setFullUrl "https://example.com/api/"
http.responseImport /tmp/something_AUTOFILE_.txt
http.responseDelete FILE
http.responseDelete
"<
FILE
>"
Delete a file after http.responseExport.
It is useful if you use the AUTOFILE mechanism.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment