mirror of
https://github.com/hassio-addons/bashio.git
synced 2025-05-06 12:01:25 +00:00
🔨 Re-branding of the Supervisor API (#16)
* 🔨 Re-branding of the Supervisor API * 🚑 Fix typo in the supervisor token
This commit is contained in:
parent
5c7f2914cd
commit
a4b2a4cc1a
15 changed files with 196 additions and 196 deletions
12
lib/api.sh
12
lib/api.sh
|
@ -17,12 +17,12 @@
|
|||
# $3 In case of a POST method, this parameter is the JSON to POST (optional)
|
||||
# $4 jq filter command (optional)
|
||||
# ------------------------------------------------------------------------------
|
||||
function bashio::api.hassio() {
|
||||
function bashio::api.supervisor() {
|
||||
local method=${1}
|
||||
local resource=${2}
|
||||
local raw=${3:-}
|
||||
local filter=${4:-}
|
||||
local auth_header='X-HASSIO-KEY;'
|
||||
local auth_header='Authorization: Bearer'
|
||||
local response
|
||||
local status
|
||||
local data='{}'
|
||||
|
@ -30,8 +30,8 @@ function bashio::api.hassio() {
|
|||
|
||||
bashio::log.trace "${FUNCNAME[0]}" "$@"
|
||||
|
||||
if [[ -n "${HASSIO_TOKEN:-}" ]]; then
|
||||
auth_header="X-HASSIO-KEY: ${__BASHIO_HASSIO_TOKEN}"
|
||||
if [[ -n "${__BASHIO_SUPERVISOR_TOKEN:-}" ]]; then
|
||||
auth_header="Authorization: Bearer ${__BASHIO_SUPERVISOR_TOKEN}"
|
||||
fi
|
||||
|
||||
if [[ "${method}" = "POST" ]] && bashio::var.has_value "${raw}"; then
|
||||
|
@ -43,7 +43,7 @@ function bashio::api.hassio() {
|
|||
-H "${auth_header}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "${data}" \
|
||||
"${__BASHIO_HASSIO_API}${resource}"
|
||||
"${__BASHIO_SUPERVISOR_API}${resource}"
|
||||
); then
|
||||
bashio::log.debug "${response}"
|
||||
bashio::log.error "Something went wrong contacting the API"
|
||||
|
@ -53,7 +53,7 @@ function bashio::api.hassio() {
|
|||
status=${response##*$'\n'}
|
||||
response=${response%$status}
|
||||
|
||||
bashio::log.debug "Requested API resource: ${__BASHIO_HASSIO_API}${resource}"
|
||||
bashio::log.debug "Requested API resource: ${__BASHIO_SUPERVISOR_API}${resource}"
|
||||
bashio::log.debug "Request method: ${method}"
|
||||
bashio::log.debug "Request data: ${data}"
|
||||
bashio::log.debug "API HTTP Response code: ${status}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue