Layer7 API Management

  • 1.  Loops in CA Policy Manager?

    Posted Aug 25, 2015 10:45 AM

    Hi All,

     

    So for Example i have json like the below,

     

    {

        "id": "1",

        "values": [

            {

                "sum": "a+b",

                "diff": "a-b"

            },

            {

                "sum1": "a+b",

                "diff2": "a-b"

            }

        ],

        "valuesId": {

            "a": {

                "b": "c"

            },

            "d": "e"

        },

        "valuesfor": [

            {

                "1": {

                    "2": "3"

                },

                "4": {

                    "5": "6"

                }

            }

        ]

    }

     

    1. How can i loop through values array ? kind of (for/forEach)

    2. How can i loop through valuesId Object?  kind of (Object.keys() / forEach)

    3. So for example i want to change the above input to the below format, how can i achieve this?

     

    {

        "id": "1",

        "values": [

            {

                "modifysum": "a+b",

                "modifydiff": "a-b"

            },

            {

                "modifysum1": "a+b",

                "modifydiff2": "A_B+A_B"

            }

        ],

        "valuesId": {

            "modifyA": {

                "soB": "SoC"

            },

            "ModifyD": "ModifyE"

        },

        "valuesfor": [

            {

                "1": {

                    "2": "3"

                },

                "4": {

                    "5": "6"

                }

            }

        ]

    }



  • 2.  Re: Loops in CA Policy Manager?

    Posted Aug 25, 2015 11:04 AM

    Take a look at the "Run Assertions for Each Item" assertion, you can use that to loop over a list of values. The Policy Manager has good documentation and examples on it.



  • 3.  Re: Loops in CA Policy Manager?

    Posted Aug 26, 2015 02:45 AM

    Can you please post an sample for the above schema ? It would be very helpful for me.



  • 4.  Re: Loops in CA Policy Manager?
    Best Answer

    Posted Aug 27, 2015 11:59 AM

    Hi Sathish2306,

     

    I do not personally have an example for you, but I wanted to point you towards this in case it helps - it is our documentation on that assertion: https://wiki.ca.com/display/GATEWAY84/Run+Assertions+for+Each+Item+Assertion

     

    Sincerely,

     

    Dustin Dauncey

    Support Engineer, Global Customer Success

    Email: API-Support@ca.com

    Phone: +1 800 225 5224

    Outside of North America - ca.com/us/worldwide.aspx

    CA API Management Community: ca.com/talkapi



  • 5.  Re: Loops in CA Policy Manager?

    Posted Aug 28, 2015 10:07 AM

    If you are having trouble with the Run assertion then we can be happy to help but we do not have samples that are specific to this use case. The implementation should not be particularly difficult. You need to select a JSON path that contains all of the child key/value pairs then use the result of that path as the foundation for a loop.



  • 6.  Re: Loops in CA Policy Manager?

    Posted Dec 10, 2015 10:08 AM

    Hello. Has this question been answered satisfactorily? If so then please take a moment to select the appropriate response as a helpful or correct answer. Thanks!