Apigee X KVM API to update entries

Hi,

Apigee X

I am using KVM API as mention in https://github.com/apigee/devrel/tree/main/references/kvm-admin-api and according to recently release (2nd of June 2022

I don't have any issue in creating KVM or KVM entries. But when I try to update existing entries in KVM using POST method I am getting below Error.

CURL:

--header 'Authorization: Bearer $TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
            "name""key-1",
            "value""Hello"
}'
Response
{
    "error": {
        "code"409,
        "message""KeyValueMapEntry key-1 already exists in map test-kvm",
        "status""ABORTED",
        "details": [
            {
                "@type""type.googleapis.com/google.rpc.PreconditionFailure",
                "violations": [
                    {
                        "type""keyvaluemap.service.KeyValueMapEntryAlreadyExists",
                        "subject""[2002:a17:90a:5d0e::]:4281:sipv5:9892:704108:27499175",
                        "description""KeyValueMapEntry key-1 already exists in map test-kvm"
                    }
                ]
            },
            {
                "@type""type.googleapis.com/google.rpc.RequestInfo",
                "requestId""786550939550115971"
            }
        ]
    }
}
 
Is there anyway to update existing KVM entries using API or are there any other API?
 
I can delete entries and recreate entries on error, but I want to avoid this implementation, as System can get unwanted errors between delete and create process.
 
CC: @dchiesa1 
 
 
 
 
 
Solved Solved
0 1 545
1 ACCEPTED SOLUTION

Hi

I developed a small shell script to create/update KVM map and entries from a JSON file (similarly to Terraform): https://github.com/arnaduga/apigee-tooling, folder kvm-terraforming

As you noticed, the current API does not allow updates (PATCH/PUT). The script will then delete an existing key prior to recreate it.

Script's limit: if a key is not described anymore in the JSON (previously declared), it will not be deleted. That would be an enhancement to do.

I hope this help, even if does not avoid the risk you mentioned...

View solution in original post

1 REPLY 1

Hi

I developed a small shell script to create/update KVM map and entries from a JSON file (similarly to Terraform): https://github.com/arnaduga/apigee-tooling, folder kvm-terraforming

As you noticed, the current API does not allow updates (PATCH/PUT). The script will then delete an existing key prior to recreate it.

Script's limit: if a key is not described anymore in the JSON (previously declared), it will not be deleted. That would be an enhancement to do.

I hope this help, even if does not avoid the risk you mentioned...