#!/bin/bash
set +e

source ${SCRIPT_DIR}/logging

set_container_status() {
  local status=$1
  local progress=$2
  local message=$3

  if [ -z "${KASM_API_HOST}" ] || [ -z "${KASM_API_JWT}" ]; then
    error "Failed to set container status: KASM_API_HOST, or KASM_API_JWT is not set"
    return 1
  fi

  http_proxy="" https_proxy="" curl -s -k "https://${KASM_API_HOST}/api/set_kasm_session_status?token=${KASM_API_JWT}" \
    -H 'Content-Type: application/json' \
    -d "{\"status\": \"${status}\", \"status_progress\": \"${progress}\", \"status_message\": \"${message}\"}" > /dev/null
}