Skip to content

Instantly share code, notes, and snippets.

@ymkjp
Last active December 25, 2017 01:22
Show Gist options
  • Save ymkjp/ff0a9f0b7e6b1e5a214b3288d2eb4727 to your computer and use it in GitHub Desktop.
Save ymkjp/ff0a9f0b7e6b1e5a214b3288d2eb4727 to your computer and use it in GitHub Desktop.
REST API で Confluence Cloud の総ページ数を知る ref: https://qiita.com/ymkjp/items/43651c1d9a60fc8ca48c
A_USER="admin"
A_PASSWD="__YOUR_PASSWORD_HERE__"
INSTANCE_HOST="__YOUR_SUBDOMAIN_HERE__.atlassian.net"
SPACE_LIMIT="1000"
function space_keys {
curl -sGLu ${A_USER}:${A_PASSWD} "https://${INSTANCE_HOST}/wiki/rest/api/space" --data-urlencode "limit=${SPACE_LIMIT}" | jq -r '.results[].key'
}
function page_num_by_space {
for SPACE in $(space_keys); do
NUM_PAGES=$(curl -sGLu ${A_USER}:${A_PASSWD} "https://${INSTANCE_HOST}/wiki/rest/api/search" --data-urlencode "cql=type IN (blogpost, page) AND space='${SPACE}'" --data-urlencode 'limit=0' | jq '.totalSize')
echo "${SPACE}\t${NUM_PAGES}"
done
}
page_num_by_space | sort -rk2
# Be sure that a user has a privilege to access all the Confluence spaces
A_USER="admin"
A_PASSWD="__YOUR_PASSWORD_HERE__"
INSTANCE_HOST="__YOUR_SUBDOMAIN_HERE__.atlassian.net"
# Total number of pages
curl -sGLu ${A_USER}:${A_PASSWD} "https://${INSTANCE_HOST}/wiki/rest/api/search" --data-urlencode 'cql=type IN (blogpost, page)' --data-urlencode 'limit=0' | jq '.totalSize'
# Total number of users
curl -sLu ${A_USER}:${A_PASSWD} "https://${INSTANCE_HOST}/wiki/rest/api/group/confluence-users/member?limit=1000" | jq '.size'
# Number of spaces (Assumed to be less than 1000)
curl -sLu ${A_USER}:${A_PASSWD} "https://${INSTANCE_HOST}/wiki/rest/api/space?limit=1000" | jq '.size'
DEF 5
BIJP 2
~admin 1
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
DEF 5
BIJP 2
~admin 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment