cli icon indicating copy to clipboard operation
cli copied to clipboard

[FEATURE REQUEST] Ability to empty an Object Store of all entries

Open JakeChampion opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. In order to delete an Object Store, it first has to be empty. Currently there is not way via the CLI to remove entries from an Object Store.

Describe the solution you'd like I'd like to be able to provide either an Object Store name or ID and have all entries deleted from the store

Describe alternatives you've considered I've written a bash function which takes an Object Store ID and deletes all the entries. It requires jq, httpie and fastly:

function empty_objectstore() {
    http "https://api.fastly.com/resources/stores/object/$1/keys" 'Accept:application/json' "Fastly-Key: $2" 'Content-Type:application/json' | jq -r '.data[]' | parallel "http DELETE '[https://api.fastly.com/resources/stores/object/$1/keys/{=1](https://api.fastly.com/resources/stores/object/$1/keys/%7B=1) uq(); =}' 'Accept:application/json' 'Fastly-Key: $2' 'Content-Type:application/json'"
}

Additional context I think this is a dangerous feature and may need to be behind an interactive prompt with a "y/N" response, where y will delete the entries and any other response will abort the action.

JakeChampion avatar Jan 18 '23 17:01 JakeChampion