Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
8 changes: 0 additions & 8 deletions GET.sh

This file was deleted.

8 changes: 5 additions & 3 deletions get-a-single-pre-receive-hook.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks-for-an-organization
# GET /admin/pre-receive-hooks/:pre_receive_hook_id
# https://docs.github.com/en/enterprise-server@3.15/rest/enterprise-admin/pre-receive-hooks?apiVersion=2022-11-28#get-a-pre-receive-hook
# GET /admin/pre-receive-hooks/{pre_receive_hook_id}

if [ -z "$1" ]
then
Expand All @@ -11,6 +11,8 @@ if [ -z "$1" ]
fi

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}/enterprise-admin/pre_receive_hooks/${pre_receive_hook_id}
"${GITHUB_API_BASE_URL}/enterprise-admin/pre_receive_hooks/${pre_receive_hook_id}"

3 changes: 1 addition & 2 deletions ghes-list-global-webhooks.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-server/rest/enterprise-admin/global-webhooks#list-global-webhooks
# https://docs.github.com/en/enterprise-server@3.15/rest/enterprise-admin/global-webhooks?apiVersion=2022-11-28#list-global-webhooks
# GET /admin/hooks


Expand All @@ -9,4 +9,3 @@ curl ${curl_custom_flags} \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/admin/hooks"


4 changes: 3 additions & 1 deletion ghes-list-public-keys.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-server/rest/enterprise-admin/users#list-public-keys
# https://docs.github.com/en/enterprise-server@3.15/rest/enterprise-admin/users?apiVersion=2022-11-28#list-public-keys
# GET /admin/keys


curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/admin/keys"

7 changes: 5 additions & 2 deletions legacy-oauth-list-your-authorizations.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-server@3.2/rest/reference/oauth-authorizations#list-your-authorizations
# https://docs.github.com/en/enterprise-server/rest/oauth-authorizations/oauth-authorizations?apiVersion=2022-11-28#list-your-authorizations
# GET /authorizations


client_id=${x_client_id}

curl ${curl_custom_flags} \

-u ${admin_user}:${admin_password} \
-H "Accept: application/vnd.github.v3+json" \
${GITHUB_API_BASE_URL}/authorizations?client_id=$client_id
"${GITHUB_API_BASE_URL}/authorizations?client_id=${client_id}":

6 changes: 4 additions & 2 deletions legacy-oauth-list-your-grants.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.2/rest/reference/oauth-authorizations#list-your-grants
https://docs.github.com/en/enterprise-server/rest/oauth-authorizations/oauth-authorizations?apiVersion=2022-11-28#list-your-grants
# GET /applications/grants


# Nothing about auth listed on the docs at above url
# document should mention: -u ${admin_user}:${admin_password} \

Expand All @@ -17,4 +18,5 @@ fi
curl ${curl_custom_flags} \
-u ${admin_user}:${admin_password} \
-H "Accept: application/vnd.github.v3+json" \
${GITHUB_API_BASE_URL}/applications/grants?client_id=${client_id}
"${GITHUB_API_BASE_URL}/applications/grants?client_id=${client_id}"

4 changes: 3 additions & 1 deletion list-artifacts-for-a-repository.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/actions#list-artifacts-for-a-repository
# https://docs.github.com/en/enterprise-cloud@latest/rest/actions/artifacts?apiVersion=2022-11-28#list-artifacts-for-a-repository
# GET /repos/{owner}/{repo}/actions/artifacts

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}/repos/${org}/${repo}/actions/artifacts"

7 changes: 5 additions & 2 deletions list-branch-default.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/git#get-a-reference
# GET /repos/:owner/:repo/git/ref/:ref
# https://docs.github.com/en/enterprise-cloud@latest/rest/git/refs?apiVersion=2022-11-28#get-a-reference
# GET /repos/{owner}/{repo}/git/ref/{ref}


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}/repos/${org}/${repo}/git/ref/heads/${base_branch}"

13 changes: 8 additions & 5 deletions list-branch-protection-status.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
. ./.gh-api-examples.conf

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


if [ -z "$1" ]
then
branch=${base_branch}
else
branch=$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}/branches/${branch}/protection"
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}/repos/${org}/${repo}/branches/${branch}/protection"

3 changes: 2 additions & 1 deletion list-codeql-databases-for-a-repository.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/code-scanning#list-codeql-databases-for-a-repository
# https://docs.github.com/en/enterprise-cloud@latest/rest/code-scanning/code-scanning?apiVersion=2022-11-28#list-codeql-databases-for-a-repository
# GET /repos/{owner}/{repo}/code-scanning/codeql/databases


Expand All @@ -14,6 +14,7 @@ fi


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}/repos/${owner}/${repo}/code-scanning/codeql/databases"
Expand Down
6 changes: 4 additions & 2 deletions list-contributors-on-repository-jq.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-all-contributor-commit-activity
# GET /repos/:owner/:repo/stats/contributors
# https://docs.github.com/en/enterprise-cloud@latest/rest/metrics/statistics?apiVersion=2022-11-28#get-all-contributor-commit-activity
# GET /repos/{owner}/{repo}/stats/contributors


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}/repos/${org}/${repo}/stats/contributors" | jq -r '.[] | "\(.author.login),\(.total)"'

7 changes: 5 additions & 2 deletions list-contributors-on-repository.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-all-contributor-commit-activity
# GET /repos/:owner/:repo/stats/contributors
# https://docs.github.com/en/enterprise-cloud@latest/rest/metrics/statistics?apiVersion=2022-11-28#get-all-contributor-commit-activity
# GET /repos/{owner}/{repo}/branches/{branch}/protection


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}/repos/${org}/${repo}/stats/contributors"

5 changes: 4 additions & 1 deletion list-deployments.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
. ./.gh-api-examples.conf

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


if [ -z "$1" ]
then
repo=${repo}
Expand All @@ -11,6 +12,8 @@ if [ -z "$1" ]
fi

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}/repos/${org}/${repo}/deployments"

5 changes: 4 additions & 1 deletion list-failed-organization-invitations.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/orgs#list-failed-organization-invitations
# https://docs.github.com/en/enterprise-cloud@latest/rest/orgs/members?apiVersion=2022-11-28#list-failed-organization-invitations
# GET /orgs/{org}/failed_invitations


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}/orgs/${org}/failed_invitations"

5 changes: 4 additions & 1 deletion list-pending-organization-invitations.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/orgs#list-pending-organization-invitations
# https://docs.github.com/en/enterprise-cloud@latest/rest/orgs/members?apiVersion=2022-11-28#list-pending-organization-invitations
# GET /orgs/{org}/invitations


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}/orgs/${org}/invitations"

2 changes: 1 addition & 1 deletion list-personal-access-tokens.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-server@3.0/rest/reference/enterprise-admin#list-personal-access-tokens
# https://docs.github.com/en/enterprise-server@3.15/rest/enterprise-admin?apiVersion=2022-11-28#list-personal-access-tokens
# GET /admin/tokens

curl ${curl_custom_flags} \
Expand Down
3 changes: 2 additions & 1 deletion list-pre-receive-hooks-for-an-organization.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-server@3.1/rest/reference/enterprise-admin#list-pre-receive-hooks-for-an-organization
# https://docs.github.com/en/enterprise-server/rest/enterprise-admin?apiVersion=2022-11-28#list-pre-receive-hooks-for-an-organization
# GET /orgs/{org}/pre-receive-hooks


Expand All @@ -12,6 +12,7 @@ if [ -z "$1" ]
fi

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}/orgs/${org}/pre-receive-hooks"
Expand Down
9 changes: 6 additions & 3 deletions list-repo-enter.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-a-repository
# GET the list of repos in the organization:
# https://docs.github.com/en/enterprise-cloud@latest/rest/repos?apiVersion=2022-11-28#get-a-repository
# GET /repos/{owner}/{repo}


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}/repos/${org}/testrepo | jq '.delete_branch_on_merge'
"${GITHUB_API_BASE_URL}/repos/${org}/testrepo" | jq '.delete_branch_on_merge'

6 changes: 4 additions & 2 deletions list-repository-contributors.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
. ./.gh-api-examples.conf

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


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

11 changes: 6 additions & 5 deletions list-single-commit.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-a-commit
# GET /repos/:owner/:repo/commits/:ref
# https://docs.github.com/en/enterprise-cloud@latest/rest/commits/commits?apiVersion=2022-11-28
# GET /repos/{owner}/{repo}/commits

repo=${1}
ref=${2}
ref=${1}

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}/repos/${org}/${repo}/commits/${ref}
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/commits/${ref}"

6 changes: 4 additions & 2 deletions list-stats.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-statistics
# https://docs.github.com/en/enterprise-server@3.15/rest/enterprise-admin?apiVersion=2022-11-28#get-statistics
# GET /enterprise/stats/{type}


curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/enterprise/stats/all
"${GITHUB_API_BASE_URL}/enterprise/stats/all"

3 changes: 1 addition & 2 deletions list-status.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
. ./.gh-api-examples.conf

shopt -s -o nounset

# https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-settings
# GET /setup/api/settings


curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
Expand Down
6 changes: 4 additions & 2 deletions remove-a-repository-collaborator.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#remove-a-repository-collaborator
# https://docs.github.com/en/enterprise-cloud@latest/rest/collaborators/collaborators?apiVersion=2022-11-28#remove-a-repository-collaborator
# DELETE /repos/{owner}/{repo}/collaborators/{username}


if [ -z "$1" ]
then
username=${default_collaborator}
else
username=$1
fi


curl ${curl_custom_flags} \
-X DELETE \
-H "X-GitHub-Api-Version: ${github_api_version}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/collaborators/${username}
"${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/collaborators/${username}"

1 change: 1 addition & 0 deletions remove-a-saml-sso-authorization-for-an-organization.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/orgs/${org}/credential-authorizations/${credential_id}"

2 changes: 1 addition & 1 deletion remove-an-organization-member.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# https://docs.github.com/en/enterprise-cloud@latest/rest/orgs/members?apiVersion=2022-11-28#remove-an-organization-member
# DELETE /orgs/{org}/members/{username}


if [ -z "$1" ]
then
username=${default_committer}
Expand All @@ -18,4 +19,3 @@ curl ${curl_custom_flags} \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/orgs/${org}/member/${username}"


3 changes: 2 additions & 1 deletion remove-organization-membership-for-a-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ curl ${curl_custom_flags} \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/orgs/${org}/memberships/${username}
"${GITHUB_API_BASE_URL}/orgs/${org}/memberships/${username}"

Loading