Hello.
I am trying to create a KVM through input variables by header or by body, but in no case it is creating this variable, it only lets me if I put mapIdentifier and it always saves the same value,
I have created a JS and an AM to set the values, but even so it does not set them as name to create the KVM.
what I do first I extract the variables in two steps so that we can set it up
EV-ParseRequestBody
<ExtractVariables name="EV-ParseRequestBody">
<JSONPayload>
<Variable name="private.kvm-entry.value" type="string">
<JSONPath>$.value</JSONPath>
</Variable>
<Variable name="kvm-entry.key" type="string">
<JSONPath>$.key</JSONPath>
</Variable>
</JSONPayload>
</ExtractVariables>
other EV-ParseRequestFormBody
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables name="EV-ParseRequestFormBody">
<FormParam name="name">
<Pattern>{kvm-entry.name}</Pattern>
</FormParam>
<FormParam name="value">
<Pattern>{private.kvm-entry.value}</Pattern>
</FormParam>
</ExtractVariables>
the next steep is the config KVM,
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations continueOnError="false" enabled="true" name="KV-CreateNewKVM" >
<DisplayName>KV-CreateNewKVM</DisplayName>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>300</ExpiryTimeInSecs>
<Put override="true">
<Key>
<Parameter ref="kvm-entry.key"/>
</Key>
<Value ref="private.kvm-entry.value"/>
</Put>
<Scope>environment</Scope>
</KeyValueMapOperations>
this not working, then I try with other config of KVM
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations continueOnError="false" enabled="true" name="KV-CreateNewKVM">
<mapIdentifier>{kvm}</mapIdentifier>
<DisplayName>KV-CreateNewKVM</DisplayName>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>300</ExpiryTimeInSecs>
<Put override="true">
<Key>
<Parameter ref="kvm-entry.key"/>
</Key>
<Value ref="private.kvm-entry.value"/>
</Put>
<Scope>environment</Scope>
</KeyValueMapOperations>
the curl
and I have also tried this KVM and the following curl
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations continueOnError="false" enabled="true" name="KV-CreateNewKVM">
<MapName ref="mapname"/>
<DisplayName>KV-CreateNewKVM</DisplayName>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>300</ExpiryTimeInSecs>
<Get assignTo="kvmData" index="1">
<Key>
<Parameter ref="request.header.kvm"/>
</Key>
</Get>
<Scope>environment</Scope>
</KeyValueMapOperations>
the curls
Any help?
thanks 🙂😀
Solved! Go to Solution.
Regarding the error you're seeing, when using the policy with MapName, as per the docs, your map must already be created - https://cloud.google.com/apigee/docs/api-platform/reference/policies/key-value-map-operations-policy...
You should either use mapidentifier with a static KVM as previously suggested or you need to create your KVM up front (Via UI or Management API)
1. How are you setting the "mapname" variable that you're using in the KVM policy MapName tag? Also, do you really need to use a variable for this? If you could provide more example on your use case, it would better help understand what you're trying to do
2. RE The MapIdentifier example, the mapIdentifier is an attribute of the KeyValueMapOperations tag, not its own tag ie
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="CreateFooKVM" mapIdentifier="FooKVM">
Hello
Hello,
I'm initializing with the header entry the map name.
we are trying to use the KVM api of daniel strevel without having to go through the GCP, but directly to the runtime, and this api has creation, modification and deletion of field & value, but not a creation of a KVM, and we are trying to create this KVM dynamically, that comes in the header and is able to create it, however the failure that is giving me to put the KVM as I expose, is that this KVM does not exist (obviously, because I am trying to create it).
The kvm
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations continueOnError="false" enabled="true" name="KV-CreateNewKVM">
<MapName ref="request.header.kvm"/>
<Scope>enviroment</Scope>
<Put override="false">
<Key>
<Parameter ref="request.header.kvm"/>
</Key>
<Key>
<Parameter ref="kvm-entry.key"/>
</Key>
<Value ref="private.kvm-entry.value"/>
</Put>
<Scope>environment</Scope>
</KeyValueMapOperations>
Regards
1. Do you have a more detailed example of what you use from the request to determine the kvm name/identifier, as well as the key and value pair/s that you then create.
2. Also, are you inserting a single key value pair into separate KVMs each time? If this is the case, you may find it better to have a single key value map, using unique keys in your key value pairs as needed
Sure
I am using daniel strevel's API, but with the modification to create a KVM from the runtime directly.
If in the EV-body I am putting and get the variable and set it
<Header name="kvm">
<Pattern ignoreCase="false">{mapname}</Pattern>
</Header>
these is the curl
Regarding the error you're seeing, when using the policy with MapName, as per the docs, your map must already be created - https://cloud.google.com/apigee/docs/api-platform/reference/policies/key-value-map-operations-policy...
You should either use mapidentifier with a static KVM as previously suggested or you need to create your KVM up front (Via UI or Management API)