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 2 years 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

Alternatively, the objectstore delete command could have a -f/--force flag to delete it ignoring any existing entries, similar to fastly service delete for an active service.

fgsch avatar Feb 06 '23 15:02 fgsch

This was implemented as fastly kv-store delete --all.

kpfleming avatar Apr 02 '25 20:04 kpfleming