#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# shellcheck source=../lib/common.sh
source "${ROOT}/lib/common.sh"

require_env TOKEN
require_env API_KEY_ID
NAME="${API_KEY_NAME:-renamed-key}"

curl_post_bearer_json "/api-key/update" "${TOKEN}" \
  "$(printf '%s' "{\"id\":\"${API_KEY_ID}\",\"name\":\"${NAME}\"}")" | pretty
