Skip to content

Instantly share code, notes, and snippets.

@smashwilson
Last active June 3, 2016 13:30
Show Gist options
  • Save smashwilson/3adb2cdf6b068dab89e91060c0113502 to your computer and use it in GitHub Desktop.
Save smashwilson/3adb2cdf6b068dab89e91060c0113502 to your computer and use it in GitHub Desktop.
Content enumeration and deletion from Nexus

Prerequisites

Listing content

Before deleting content in production, it's a good idea to make sure you know what you're about to delete. You can list the content IDs that are currently present in Nexus by visiting the /content/ endpoint:

https://developer.rackspace.com:9000/content/

List content IDs that begin with a specific base by providing a URL-encoded ?prefix= parameter, such as:

https://developer.rackspace.com:9000/content?prefix=https%3A%2F%2Fgithub.com%2Frackerlabs%2Fdocs-dedicated-vcloud

Results are returned 100 at a time. You can paginate (awkwardly) by adding &pageNumber=2 to the end of the URL. The full documentation is in the content service README.

Deleting content

Delete individual envelopes by using curl to issue a DELETE request to the content service API, using the URL-encoded content ID:

export APIKEY="..."

curl -X DELETE -H "Authorization: deconst ${APIKEY}" \
  https://developer.rackspace.com:9000/content/https%3A%2F%2Fgithub.com%2Frackerlabs%2Fdocs-dedicated-vcloud

(You can copy and paste the /content/... bit from the url key in the search results in your browser.)

To bulk delete all envelopes beneath a content ID base that you've removed or renamed, specify the ?prefix=true parameter:

export APIKEY="..."

curl -X DELETE -H "Authorization: deconst ${APIKEY}" \
  https://developer.rackspace.com:9000/content/https%3A%2F%2Fgithub.com%2Frackerlabs%2Fdocs-dedicated-vcloud?prefix=true

The documentation for this endpoint is also in the content service README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment