Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up preview headers in REST" #267

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions add-an-email-address-for-the-authenticated-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,21 @@
# POST /user/emails


json_file=tmp/skeleton.json

ts=$(date +%s)
emails="test+n${ts}@example.com"

json_file=tmp/add-an-email-address-for-the-authenticated-user.json

jq -n \
--arg emails "${emails}" \
'{
"emails" : [ $emails ]
}' > ${json_file}


cat $json_file | jq -r

curl ${curl_custom_flags} \
-H "X-GitHub-Api-Version: ${github_api_version}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/user/emails --data @${json_file}


"${GITHUB_API_BASE_URL}/user/emails" --data @${json_file}

3 changes: 2 additions & 1 deletion add-badteam-to-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ curl ${curl_custom_flags} \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/orgs/${org}/teams/${team_slug}/repos/${org}/${repo}
"${GITHUB_API_BASE_URL}/orgs/${org}/teams/${team_slug}/repos/${org}/${repo}"

2 changes: 1 addition & 1 deletion add-maintainers-to-team.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ team_id=$(curl ${curl_custom_flags} -H "Authorization: Bearer ${GITHUB_TOKEN}" $
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/teams/${team_id}/memberships/${team_admin} --data '{ "role": "maintainer"}'
"${GITHUB_API_BASE_URL}/teams/${team_id}/memberships/${team_admin}" --data '{ "role": "maintainer"}'
2 changes: 1 addition & 1 deletion add-many-owners-one-organization.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ do
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/orgs/${org}/memberships/${user} --data '{"role": "admin"}'
"${GITHUB_API_BASE_URL}/orgs/${org}/memberships/${user}" --data '{"role": "admin"}'
done
2 changes: 1 addition & 1 deletion add-many-users-to-org.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ do
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/orgs/${org}/memberships/${person}
"${GITHUB_API_BASE_URL}/orgs/${org}/memberships/${person}"
done
2 changes: 1 addition & 1 deletion add-many-users-to-team.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ do
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/teams/${team_id}/memberships/${team_member}
"${GITHUB_API_BASE_URL}/teams/${team_id}/memberships/${team_member}"
done
6 changes: 1 addition & 5 deletions add-or-update-team-repository-permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@ curl ${curl_custom_flags} \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/orgs/${org}/teams/${team_slug}/repos/${org}/${repo} --data @${json_file}




"${GITHUB_API_BASE_URL}/orgs/${org}/teams/${team_slug}/repos/${org}/${repo}" --data @${json_file}
1 change: 0 additions & 1 deletion add-owner-to-many-organizations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ do
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/orgs/${org}/memberships/${user}" --data '{"role": "admin"}'

done
4 changes: 2 additions & 2 deletions add-repository-to-an-app-installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ installation_id=${default_installation_id}
curl -v ${curl_custom_flags} \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.machine-man-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/user/installations/${installation_id}/repositories/${repository_id}
"${GITHUB_API_BASE_URL}/user/installations/${installation_id}/repositories/${repository_id}"

4 changes: 2 additions & 2 deletions add-team-to-org-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ json_file=test-data/team-permissions.json
curl ${curl_custom_flags} \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.inertia-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/orgs/${org}/teams/${team_slug}/projects/${project_id} --data @${json_file}
"${GITHUB_API_BASE_URL}/orgs/${org}/teams/${team_slug}/projects/${project_id}" --data @${json_file}

1 change: 1 addition & 0 deletions add-team-to-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/teams/${team_id}/repos/${org}/${repo}" --data @${json_file}

5 changes: 1 addition & 4 deletions add-user-access-restrictions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [ -z "$1" ]
username=$1
fi

json_file="tmp/add-user-access-restrictions"
json_file="tmp/add-user-access-restrictions.json"

jq -n \
--arg username "${username}" \
Expand All @@ -26,9 +26,6 @@ cat $json_file | jq -r
branch=${protected_branch_name}



set -x

curl ${curl_custom_flags} \
-H "X-GitHub-Api-Version: ${github_api_version}" \
-H "Accept: application/vnd.github.v3+json" \
Expand Down
3 changes: 1 addition & 2 deletions add-user-to-org.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
# https://docs.github.com/en/enterprise-server@3.10/rest/orgs/members?apiVersion=2022-11-28#set-organization-membership-for-a-user
# PUT /orgs/{org}/memberships/{username}

json_file=tmp/set-organization-membership-for-a-user.json

role="member"

json_file=tmp/set-organization-membership-for-a-user.json
jq -n \
--arg role "${role}" \
'{
Expand Down
5 changes: 3 additions & 2 deletions add-user-to-team.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
# If the script is passed an argument $1 use that as the team name
if [ -z "$1" ]
then
team_slug=$team_slug
team_slug=${team_slug}
else
team_slug=$1
fi

# If the script is passed an argument $1 use that as the user name
if [ -z "$2" ]
then
team_member=$default_committer
team_member=${default_committer}
else
team_member=$2
fi
Expand All @@ -28,3 +28,4 @@ curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/teams/${team_id}/memberships/${team_member}"

2 changes: 1 addition & 1 deletion add-users-to-org.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ do
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/orgs/${org}/memberships/${person}
"${GITHUB_API_BASE_URL}/orgs/${org}/memberships/${person}"
done
3 changes: 2 additions & 1 deletion add-users-to-team.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ do
echo "======================== ${team_member} ==========================" >&2
curl --silent ${curl_custom_flags} \
-X PUT \
-H "Authorization: Bearer ${GITHUB_TOKEN}" ${GITHUB_API_BASE_URL}/teams/${team_id}/memberships/${team_member}
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/teams/${team_id}/memberships/${team_member}"
done
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.dorian-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/repos/${org}/${repo}/vulnerability-alerts
7 changes: 4 additions & 3 deletions create-a-pre-receive-hook.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-server@3.1/rest/reference/enterprise-admin#create-a-pre-receive-hook
# https://docs.github.com/en/enterprise-server/rest/enterprise-admin/pre-receive-hooks?apiVersion=2022-11-28#create-a-pre-receive-hook
# POST /admin/pre-receive-hooks


json_file=tmp/pre-receive-hook-details.json

jq -n \
Expand All @@ -22,8 +23,8 @@ jq -n \
allow_downstream_configuration: $allow_downstream_configuration | test("true")
}' > ${json_file}


curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.eye-scream-preview" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/admin/pre-receive-hooks --data @${json_file}
"${GITHUB_API_BASE_URL}/admin/pre-receive-hooks" --data @${json_file}
1 change: 0 additions & 1 deletion create-a-repository-for-the-authenticated-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jq -n \
set -x
curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.nebula-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/user/repos --data @${json_file}

14 changes: 7 additions & 7 deletions create-draft-pull-request.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/pulls#create-a-pull-request
# POST /repos/:owner/:repo/pulls
# https://docs.github.com/en/enterprise-cloud@latest/rest/pulls/pulls?apiVersion=2022-11-28#create-a-pull-request
# POST /repos/{owner}/{repo}/pulls

json_file="create-pull-request.json"
rm -f ${json_file}

timestamp=$(date +%s)
title="Amazing new feature PR: $timestamp"

lorem_file="lorem-pull-request.md"
lorem_file="test-data/lorem-pull-request.md"
lorem_text=$(cat $lorem_file)


json_file="create-pull-request.json"

jq -n \
--arg title "$title (started as draft PR)" \
--arg body "${lorem_text}" \
Expand All @@ -30,6 +30,6 @@ jq -n \

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H 'Accept: application/vnd.github.shadow-cat-preview+json' \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/repos/${org}/${repo}/pulls --data @${json_file}
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/pulls" --data @${json_file}

1 change: 0 additions & 1 deletion create-n-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ do

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.nebula-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/orgs/${org}/repos --data @${json_file} | jq -r '"\(.id),\(.full_name)"'
done
Expand Down
1 change: 0 additions & 1 deletion create-organization-project-columns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ do

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.inertia-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/projects/${project_id}/columns --data @${json_file}
cat ${json_file}
Expand Down
1 change: 0 additions & 1 deletion create-organization-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ echo ${DATA} > ${json_file}

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.inertia-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/orgs/${org}/projects --data @${json_file}

Expand Down
1 change: 0 additions & 1 deletion create-pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jq -n \

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.switcheroo-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/repos/${org}/${repo}/pages --data @${json_file}

Expand Down
1 change: 0 additions & 1 deletion create-project-card.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ json=project-card-note.json
curl ${curl_custom_flags} \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.inertia-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/projects/columns/${column_id}/cards --data @${json}
1 change: 0 additions & 1 deletion create-project-repo-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ if [ ${wanted} == "preview" ]; then
curl ${curl_custom_flags} \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.inertia-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/repos/${org}/${repo}/projects --data @${json_file}
else
Expand Down
1 change: 0 additions & 1 deletion create-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jq -n \

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.nebula-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/orgs/${org}/repos --data @${json_file}

1 change: 0 additions & 1 deletion disable-pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
curl ${curl_custom_flags} \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.switcheroo-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/repos/${org}/${repo}/pages
19 changes: 19 additions & 0 deletions get-a-pull-request.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-cloud@latest/rest/pulls/pulls?apiVersion=2022-11-28
# GET /repos/{owner}/{repo}/pulls/{pull_number}


if [ -z "$1" ]
then
pull_number=${default_pull_request_id}
else
pull_number=$1
fi


curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/pulls/${pull_number}"

11 changes: 11 additions & 0 deletions get-all-repository-topics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-all-repository-topics
# GET /repos/{owner}/{repo}/topics


curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/topics"

4 changes: 1 addition & 3 deletions get-an-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ fi
# This version is set up to work on GHES:
JWT=$(./tiny-call-get-jwt.sh 2>/dev/null)

set -x
curl ${curl_custom_flags} \
-H "Authorization: Bearer ${JWT}" \
-H "Accept: application/vnd.github.machine-man-preview+json" \
${GITHUB_API_BASE_URL}/app/installations
"${GITHUB_API_BASE_URL}/app/installations"


4 changes: 2 additions & 2 deletions get-code-of-conduct.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name=${1:-contributor_covenant}

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: Accept: application/vnd.github.scarlet-witch-preview+json" \
-H "Accept: application/vnd.github.VERSION.raw" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/codes_of_conduct/${name}
"${GITHUB_API_BASE_URL}/codes_of_conduct/${name}"

1 change: 0 additions & 1 deletion get-commit-signature-protection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.zzzax-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/repos/${org}/${repo}/branches/${protected_branch_name}/protection/required_signatures
1 change: 0 additions & 1 deletion get-project-permission-for-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ project_id=1

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Accept: application/vnd.github.inertia-preview+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/projects/${project_id}/collaborators/${username}/permission
1 change: 0 additions & 1 deletion graphql-count-pull-request-comments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ graphql_script="$(echo ${graphql_script//\"/\\\"})"

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H 'Accept: application/vnd.github.audit-log-preview+json' \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_APIV4_BASE_URL} -d "{ \"query\": \"$graphql_script\"}"

1 change: 0 additions & 1 deletion graphql-count-team-members.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jq -n \

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H 'Accept: application/vnd.github.audit-log-preview+json' \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_APIV4_BASE_URL} -d @${json_file} | jq

Expand Down
1 change: 0 additions & 1 deletion graphql-create-enterprise-ip-allow-list-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jq -n \

curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H 'Accept: application/vnd.github.audit-log-preview+json' \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_APIV4_BASE_URL} -d @${json_file} | jq

Expand Down
Loading