#!/bin/bash

VAULT_TOKEN=$(curl -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login | jq -r '.auth.client_token')
NOCODB_TOKEN=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')

echo "Getting current column config..."

# Get current column
curl -s "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc" \
  -H "xc-token: $NOCODB_TOKEN" | jq '.colOptions'

echo ""
echo "Updating colOptions for type column..."

# Update colOptions via the options endpoint
curl -s -X POST "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc/colOptions/options" \
  -H "xc-token: $NOCODB_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "options": [
      {"title": "correction", "color": "#FF0000"},
      {"title": "preference", "color": "#00FF00"},
      {"title": "episode", "color": "#0000FF"},
      {"title": "decision", "color": "#FFFF00"},
      {"title": "validation", "color": "#FF00FF"}
    ]
  }'

echo ""
echo "Done!"
