Last active
January 29, 2019 17:12
-
-
Save lucashalbert/593ce7910ef6778b5c0c91c45cf1cdec to your computer and use it in GitHub Desktop.
Deletes all iterable spaces in Confluence Cloud using the RESTful API. Requires the jq json utility.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#################################################################################### | |
# | |
# Author: Lucas Halbert <https://www.lhalbert.xyz> | |
# Date: 01/25/2019 | |
# Last Edited: 01/25/2019 | |
# Version: 2019.01.25 | |
# Description: Leverage the Confluence Cloud RESTful API to batch delete all | |
# iterable spaces. | |
# License: BSD 3-Clause License | |
# | |
# Copyright (c) 2018, Lucas Halbert | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# | |
# * Redistributions of source code must retain the above copyright notice, this | |
# list of conditions and the following disclaimer. | |
# | |
# * Redistributions in binary form must reproduce the above copyright notice, | |
# this list of conditions and the following disclaimer in the documentation | |
# and#or other materials provided with the distribution. | |
# | |
# * Neither the name of the copyright holder nor the names of its | |
# contributors may be used to endorse or promote products derived from | |
# this software without specific prior written permission. | |
# | |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
# | |
#################################################################################### | |
# | |
# Revisions: 01/25/2019 Initial Draft | |
# | |
#################################################################################### | |
BASE_URL="https://domain.atlassian.net" | |
USERNAME="user@domain.tld" | |
API_TOKEN="" | |
# Loop through iterable spaces in Confluence Cloud and capture space key | |
for i in $(curl -s -S -u ${USERNAME}:${API_TOKEN} -X GET ${BASE_URL}/wiki/rest/api/space?limit=1000 | jq '.results[].key' | tr -d '"'); do | |
echo Deleting Space ${i} | |
curl -s -S -u ${USERNAME}:${API_TOKEN} -X DELETE ${BASE_URL}/wiki/rest/api/space/${i} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment