#!/usr/bin/env bash # Thin wrapper around the Dokploy API. # # Usage: # scripts/api.sh project.all # scripts/api.sh application.one applicationId=q_TboJiWsBtn6PRD3BfIO # scripts/api.sh application.deploy '{"applicationId":"..."}' # # GET when the arg looks like key=value query params (or none); POST when given JSON. set -euo pipefail cd "$(dirname "$0")/.." set -a; source .env; set +a endpoint="$1"; shift || true if [[ $# -gt 0 && $1 == \{* ]]; then curl -s --fail-with-body -X POST \ -H "x-api-key: $DOKPLOY_API_KEY" -H "Content-Type: application/json" \ "$DOKPLOY_URL/api/$endpoint" -d "$1" else query="" for kv in "$@"; do query="${query:+$query&}$kv"; done curl -s --fail-with-body \ -H "x-api-key: $DOKPLOY_API_KEY" \ "$DOKPLOY_URL/api/$endpoint${query:+?$query}" fi echo