Route rule Condition based on comma separated KVM values

I'm trying to define a route rule where request is sent to a certain target only for certain client_ids. I don't want to hard-code these client ids in the proxy but instead get them from KVM. I will keep them in KVM as a comma-separated list.

In my Route Rule defintion, I want to check if apigee.client_id is present as one of the values retrieved from this KVM and route to this target.

How can I do that?

Essentially I'm expecting an IN condition which does not exist.

<Condition>(apigee.client_id IN KVM.client_ids)</Condition>

I will use this proxy for a canary deployment so I can control and add clients to this target.

Solved Solved
0 2 380
1 ACCEPTED SOLUTION

yes I get it.

Unfortunately there is no condition expression in Apigee that allows you to evaluate that.

The way I would do it:

run some Javascript that performs the check.

var clientId = context.getVariable('apigee.client_id');
var canaryList = context.getVariable('KVM.client_ids');

context.setVariable('canary-client', canaryList.indexOf(clientId)>=0);

And then use that variable in your condition:

<Condition>canary-client is true</Condition>

View solution in original post

2 REPLIES 2

yes I get it.

Unfortunately there is no condition expression in Apigee that allows you to evaluate that.

The way I would do it:

run some Javascript that performs the check.

var clientId = context.getVariable('apigee.client_id');
var canaryList = context.getVariable('KVM.client_ids');

context.setVariable('canary-client', canaryList.indexOf(clientId)>=0);

And then use that variable in your condition:

<Condition>canary-client is true</Condition>

this solution works just as fine. thanks a lot.