General Functions

General Functions#

HTTP Functions#

Function

Description

DELETE

Executes a HTTP DELETE request

DOWNLOAD

Downloads a file with HTTP

GET

Executes a HTTP GET request

HEAD

Executes a HTTP HEAD request

OPTIONS

Executes a HTTP OPTIONS request

PATCH

Executes a HTTP PATCH request

POST

Executes a HTTP POST request

PUT

Executes a HTTP PUT request

restsh.download

Download a file in chunks (default 512kB).

restsh.http

Generic http request function

restsh.upload

Uploads a file in chunks (default 512kB).

Utility Functions#

Function

Description

COLUMN

Replacement for the column command, separator is tab.

JQ

Shortcut to call jq.

JQE

Shortcut to call jq, exits with 1 on null or false.

KV

Print Key/Value pairs

MO

Shortcut to call the mustache template engine.

XARGS

Shortcut for xargs, running the command sequentially and only with one parameter.

echo_err

Prints red error messages to STDERR.

echo_ok

Prints green ok messages to STDOUT.

echo_verbose

Prints message only if VERBOSE is set to 1

echo_warn

Prints yellow warning messages to STDERR.

print_json_err

Prints red error message in JSON format to STDERR.

print_json_err_curl

Prints red error message in JSON format to STDERR for curl.

print_json_ok

Prints green ok message in JSON format to STDOUT.

print_json_ok_curl

Prints green ok message in JSON format to STDOUT for curl.

print_json_warn

Prints yellow warning message in JSON format to STDOUT.

print_json_warn_curl

Prints yellow warning message in JSON format to STDOUT for curl.

restsh.util.array.includes

Check if first argument is in array (following arguments)

restsh.util.array.string

Converts an array to a quoted string

restsh.util.askpass

Asks for a secret string.

restsh.util.base64url

Encodes string as Base64URL.

restsh.util.check.bool

Returns 1 if value is not a boolean

restsh.util.check.filename

Validates a value.

restsh.util.check.isnumber

Returns 1 if value is not a number

restsh.util.check.isvarname

Returns 1 if value is not a valid variable name

restsh.util.check.notempty

Returns 1 if value is undefined, length is zero, contains only whitespaces or is null

restsh.util.check.string

Validates a value.

restsh.util.check.uint

Returns 1 if value is not an unsigned integer

restsh.util.check.varnotempty

Returns 1 if variable reference is undefined, length is zero, contains only whitespaces or is null

restsh.util.declare.var

Declares a variable KEY=VALUE

restsh.util.eval_stage_var

Tries to resolve the staging variable.

restsh.util.filesize

Get file size

restsh.util.isencrypted

Checks for AES256: prefix of provided string.

restsh.util.json_validate

JSON validation, pipe string to stdin

restsh.util.jsonencode

JSON encoding

restsh.util.lc

Convert string to lower case.

restsh.util.parseoutput

Parses a command output.

restsh.util.setcurloptions

Sets the RESTSH_CURL_OPTIONS environment variable.

restsh.util.setvar

Declares a variable from a file. .txt extension for simple variable, .array for array.

restsh.util.setvars

Declares variables from a directory. .txt extension for simple variables, .array for arrays.

restsh.util.trim

Trim leading and trailing whitespaces.

restsh.util.uc

Convert string to upper case.

restsh.util.urlencode

URL encoding

restsh.util.var.decrypt

Decrypts a variable or fetches it from HashiCorp Vault.

Vault Functions#

Function

Description

vault.get

Get value from Vault

vault.login

Detects the Vault login method and tries to fetch a Vault token.

vault.login.jwt

Login into Vault with VAULT_ID_TOKEN

vault.logout

Logout from Vault