Search code examples
key-valueapigeekey-value-store

Why does Apigee Key/Value Map has such format


I'm trying to understand why Apigee has such a format for Key/Value maps. When creating a key you should POST a JSON like this:

{
    "name": "Map_name",
    "entry": [
        {
            "name": "Key1",
            "value": "value_one"
        }, {
            "name": "Key2",
            "value": "value_two"
        }
    ]
}

Note that entry is an array.

When you'r accessing a Key/Value Map you should use a policy like this:

<KeyValueMapOperations mapIdentifier="Map_name">
    <Scope>environment</Scope>
    <Get assignTo="foo_variable" index="2">
        <Key>
            <Parameter>Key2</Parameter>
        </Key>
    </Get>
</KeyValueMapOperations>

As you see, you need to specify both key name and index! Isn't it redundant? Accessing values by index is a bit inconvenient... That's not saying it is 1-based (so Pascal!). Why should I even care about the indices?


Solution

  • I think each key is multi-valued array within the Map. So each key can have more than one values. The array index is for identifying values within the multi-valued key. Not for the entire Map.