Hello,
I will explain the scenario in detail first,
I have various domains under my current organisation and every domain has list of backend APIs. We were already using a different API gateway(Kong) earlier using which our current customers are invoking all of these APIs. Now we want to migrate these to Apigee. The Proxy endpoint is different than the target endpoint and the differences are various levels.
First difference is, it is a multi-tenant system. And the customer tenant information(customer domain) is passed in header. To handle this in Apigee I have used the ExtractVariable policy and modified target URL in JavaScript policy.
Sometimes, the proxy endpoint URL and target URL differs in request URI structure, this is where I want to use KeyValuMaps
Earlier I was using only Javascript policy with many if & else to detect and modify the target URL, as followed,
var request_uri = context.getVariable('request.uri');
if(request_uri == "/payroll/v2/employees/handentry" && !targetModified)
{
targetUrl = targetUrl + "/payroll/items/employee";
targetModified = true;
}
if(request_uri == "/payroll/v2/employees/"+empId && !targetModified)
{
targetUrl = targetUrl + "/payroll/items/employee/"+empId;
targetModified = true;
}
Then I came across KeyValueMaps in Apigee.
Now if I want to implement same in KeyValueMap Operations policy, how I can do this is the question?
I already created a policy and made all necessary initial entries, but then as the key is going to be a variable here, how can we retrieve the value using variable from KeyValueMap in policy?
Also, based on what I described, are we using correct ways to migrate to Apigee?