#!/usr/bin/env bash

USERNAME="cyteen"
PASSWORD="mlpfinsonik"
# RELEASE="unstable"
# RELEASE="excalibur"
RELEASE="ceres"
COMPONENT="main"
ARCH=$(dpkg --print-architecture)

declare -A DEBS

# DEBS["libhyprlang2"]="0.5.1"
# DEBS["libhyprlang2-dbgsym"]="0.5.1"
# DEBS["libhyprlang2-dev"]="0.5.1"
DEBS["hyprwayland-scanner"]="0.1.0"

for key in "${!DEBS[@]}"; do
	PACKAGE="${key}"
	VERSION="${DEBS[$key]}"

	echo "PACKAGE: ${PACKAGE}"
	echo "VERSION: ${VERSION}"

	# Construct the URL for each package within the loop
	# GITEA_URL="https://git2.ring-zero.co.uk/api/v1/packages/${USERNAME}/debian/pools/${RELEASE}/${COMPONENT}/${PACKAGE}/${VERSION}/${ARCH}"
	GITEA_URL="https://git2.ring-zero.co.uk/api/v1/packages/${USERNAME}/debian/${PACKAGE}/${VERSION}"

	echo ${GITEA_URL}
	# Use the constructed URL in the curl command
	curl --user ${USERNAME}:${PASSWORD} \
		-X DELETE \
		-H 'accept: application/json' \
		"${GITEA_URL}"
done

# show available packages
curl -s --url https://cyteen:mlpfinsonik@git2.ring-zero.co.uk/api/v1/packages/cyteen/ | jq '.[] | select(.type == "debian") | {type, name, version, html_url, created_at}'
