"Create or Update" KVM entries using APIGeeCLI

I am using APIGee CLI to create entries in the KVM and so far, so good... but there is one scenario that seems to be too simple and somehow the workaround I've found is too complex...

In the pipeline, I want the proxy to be deployed and for all KVM entries to be created, and in case it's already there, to update the value with the new one (or omit if it's the same value).

 

I am using the following command to create them:

$ apigeecli kvms entries create -o <ORG> -e <ENV> -m <KVM> -k <KEY> -l <VALUE> --no-output
 
But if it's already there, I actually need to perform an update, but since the CLI doesn't have an update option, I have to:
- List the entries
- Check one by one if mine exists (and if is new, just create it)
- Get the entry, and check if the content is the same
- If it's a new content of a pre-existent key, I need to delete it, and then create it again
 
Seems like too long for an operation that should be there...
 
Am I missing something?
 
The "apigeecli kvms entries --help" command is not mentioning any other command to sort this out.
2 1 246
1 REPLY 1


@gcorbetta wrote:
Am I missing something?
 

 

No, you are not. 

I think you want to insert a value if it is not present, or update the value if it is present and different. Borrowing from database parlance, we can call the idea "Upsert".  There is no primitive in the  REST API for Apigee keyvaluemaps that performs upsert.  So you need to do the maybe-insert-and-maybe-update thing "manually". 

Here's a repo with a nodejs utility that does KVM Upsert. Keep in mind: Upsert is not an atomic operation.  There is a DELETE then a POST, in the case of an existing entry.  

@srinandans What is the possibility that apigeecli will support upsert at some point?