Layer7 API Management

  • 1.  key:=value pair assertion

    Posted Mar 14, 2017 04:15 AM

    Hi there,

    is there a possibility to create a list/array with key:=value pairs and later on make a lookup for the key, but return the corresponding value? As of now, I only found the multivalued variable. Or do I have to create such functionality with a complex logic by myself?
    Thank you!

     

    Ciao Stefan



  • 2.  Re: key:=value pair assertion
    Best Answer

    Broadcom Employee
    Posted Mar 14, 2017 10:07 AM

    Hi StefanKlotz,

     

    This will depend on your use case, but you may want to explore using JSON for the key/value pair and the "Evaluate JSON path expression" assertion to retrieve the values.

     

    Returns:

    Ref:

    Evaluate JSON Path Expression Assertion - CA API Gateway - 9.2 - CA Technologies Documentation 

     

    Regards,

    Joe



  • 3.  Re: key:=value pair assertion

    Posted Mar 14, 2017 10:25 AM

    Hi Stefan

     

    You can use multivalued variables (which are kind of lists or arrays) to 

    • iterate over the collection ("run assertions for each item")
    • look up a value by index ("Look up item by index position")
    • BUT (as far as I know) you can't lookup a value by key

     

    Look up values by key is a Map feature. For a Map you have (as far as I know) the following options:

    • If your Map is static you can use the "Map value" assertion
    • If you need a dynamic Map you could perhaps "misuse" the cache assertions (store to cache, lookup in cache)
      • Please note that the cache assertions do not work cluster-wide. So, if you have a gateway-cluster and you use these assertions, each gateway has its own version of the cache. 
    • If you need a cluster-wide dynamic Map you have to use a distributed cache (Hazelcast, Terracotta etc) and look the values up through HTTP calls

     

    Regards

    Stephan