There is a docs issue and the “Key Value Map Operations” policy itself seems to be incomplete (as of 04/24/2015).
This is what I wanted to do:
- Create a new KVMap List using the KeyValueMapOperations policy
- Add new keys in my KVMap list - I thought I should be able to call KVMap with InitialEntries and pass the key be reference
- Retrieve keys by reference
Creating a new KVMap List
Well, I thought this would work:
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" >
<DisplayName>KV_Default_Missing_MapID</DisplayName>
<FaultRules/>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>-1</ExpiryTimeInSecs>
<InitialEntries>
<Entry>
<Key>
<Parameter>k1</Parameter>
</Key>
<Value>v1</Value>
</Entry>
<Entry>
<Key>
<Parameter>k2</Parameter>
</Key>
<Value>v3</Value>
<Value>v4</Value>
</Entry>
</InitialEntries>
<Scope>organization</Scope>
</KeyValueMapOperations>
Yeah, that’s the KVMap policy you drag over…but where is the mapID?
OK, so changing it:
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="KV_CreateNewEntry" mapIdentifier="DynamicCreationKVMapper">
<DisplayName>KV_CreateNewEntry</DisplayName>
<FaultRules/>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>-1</ExpiryTimeInSecs>
<InitialEntries>
<Entry>
<Key>
<Parameter>JamesBrown</Parameter>
</Key>
<Value>InitialEntries_section</Value>
</Entry>
</InitialEntries>
<Scope>organization</Scope>
</KeyValueMapOperations>
…works. Now, this will create a NEW KVMap list called ‘DynamicCreationKVmapper’.
Creating new Entries and Keys by Reference
The docs(http://apigee.com/docs/api-services/reference/key-value-map-operations-policy#elementreference) lead you to believe that you can create InitialEntries by reference i.e. key is a reference parameter. That doesn’t work.
But, you can PUT new entries into the KVMap List:
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="KV-Update-Key" mapIdentifier="DynamicCreationKVMapper">
<DisplayName>KV Update Key</DisplayName>
<FaultRules/>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>-1</ExpiryTimeInSecs>
<Put override="true">
<Key>
<Parameter ref="key2_ev_policy"></Parameter>
</Key>
<Value ref="myvalvar1"/>
</Put>
<Scope>organization</Scope>
</KeyValueMapOperations>
Docs match…just wasn’t clear that a PUT will create a new entry vs. expect it to be there and error out if not present.
Updating the entry requires that “Put override=‘true’”!!!
Get the Entry using Key by reference
Well, this is the most straightforward and the docs were correct but the policy was missing the mapID. So, this works:
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="KV-Get-Key" mapIdentifier="DynamicCreationKVMapper">
<DisplayName>KV Get Key</DisplayName>
<FaultRules/>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>-1</ExpiryTimeInSecs>
<Get assignTo="VALUE_key2_ev_policy_first_entry" index="1">
<Key>
<Parameter ref="key2_ev_policy"></Parameter>
</Key>
</Get>
<Scope>organization</Scope>
</KeyValueMapOperations>
@Tom Berwick - hope this helps.
hmmm…Maybe, I should create a video with these flows…let’s see what the community says!