Syntax highlighting of itnotes/httpie-jq

= http =

<<TableOfContents()>>

[[https://httpie.org/]]
[[https://devhints.io/httpie|cheatsheets|class=" moin-https"]]

{{{#!highlight bash
# Custom [HTTP method], [HTTP headers] and [JSON] data:
http PUT example.org X-API-Token:123 name=John

# POST method with json
http :3000/api/v1/widget/users foo=bar user:='{"email": "user@example.com", "password": "1qazxdr5"}'

# submitting forms
http -f POST example.org hello=World

# See the request that is being sent using one of the output options
http -v yandex.ru

# Upload a file using [redirected input](https://httpie.org/doc#redirected-input):
http example.org < file.json

# Download a file and save it via [redirected output](https://httpie.org/doc#redirected-output):
http example.org/file > file

}}}

== Auth ==

=== JWT ===

Вариант 1

{{{#!highlight bash
http http://httpbin.org/bearer "Authorization: Bearer secrettoken"

}}}

Вариант 2

https://httpie.io/docs#auth-plugins

[[https://github.com/teracyhq/httpie-jwt-auth|httpie-jwt-auth|class=" moin-https"]]

{{{#!highlight bash
pip install -U httpie-jwt-auth
export JWT_AUTH_TOKEN=secret
http teracy.com --auth-type=jwt -v

}}}

= jq =

[[https://stedolan.github.io/jq/]]

{{{#!highlight bash
# --- первый элемент массив в поле data
http :8001/services | jq .data[0]
# --- все поля `name` в массиве data
http :8001/services | jq .data[].name

}}}

Выход со кодом ошибки

{{{#!highlight bash
http $LINT_URL PRIVATE-TOKEN:$TOKEN content=@$TARGET_FILE | jq -e '.status == "valid"'
echo $?
0
http $LINT_URL PRIVATE-TOKEN:$TOKEN content=@$TARGET_FILE | jq -e '.status == "valid1"'
echo $?
1

}}}

Поле с точкой

{{{#!highlight bash
# --- jq -r уберет кавычки у значения jmxremote.access
k get secret jmxremote -o json | jq '.data."jmxremote.access"'

}}}