GITLAB_API_PRIVATE_TOKEN="Your_API_Token_Here"
GITLAB_API_ENDPOINT="https://gitlab-server.fqdn/api/v4"
curl () {
command curl -sSL \
--header "PRIVATE-TOKEN: ${GITLAB_API_PRIVATE_TOKEN}" \
"$@"
}
curl "$GITLAB_API_ENDPOINT/groups" | jq .
curl "$GITLAB_API_ENDPOINT/groups/1234" | jq .
curl "$GITLAB_API_ENDPOINT/groups/1234/projects" | jq .
curl "$GITLAB_API_ENDPOINT/groups/1234/projects" | jq -r -c '.[].name'
while read -r project_id
do
curl -sSL --request PUT \
--header "PRIVATE-TOKEN: ${GITLAB_API_PRIVATE_TOKEN}" \
"${GITLAB_API_ENDPOINT}/projects/$project_id?visibility=internal" \
| jq .
done < <(curl -sSL --request GET \
--header "PRIVATE-TOKEN: ${GITLAB_API_PRIVATE_TOKEN}" \
"${GITLAB_API_ENDPOINT}/groups/3108/projects?per_page=500" \
| jq '.[].id')