Hi,
I am trying to use KVM to store certain user specific information (small data content) and wanted to confirm certain points:
1. Is it possible to share data stored in KVM across multiple proxies?
2. Is KVM consistent in a clustered environment, i.e. is KVM data shared in a distributed environment?
3. Is it possible to remove data from KVM?
4. Is it possible to fetch data from request headers and put in KVM?
Please share a proxy example that is using KVM, it would be of great help!
Thanks!
1. Is it possible to share data stored in KVM across multiple proxies?
yes, You can use Keyvalue Map policy with the same keyvaluemap across proxies, [Pls note the scope and the name]
2. Is KVM consistent in a clustered environment, i.e. is KVM data shared in a distributed environment?
yes, pls note it will be eventually consistent
3. Is it possible to remove data from KVM?
yes, you can add/update/remove entries from KVM
4. Is it possible to fetch data from request headers and put in KVM?
yes, you can extract any information from request headers [request.header.*] and add it to KVM
More information and samples here, http://apigee.com/docs/api-services/reference/key-value-map-operations-policy
Thanks Mukundha for a detailed reply. I managed to use KVM across proxies.
Now, I want to deny access to a proxy based on a condition. The condition will Get value from KVM and match it against a request param. If the value from request param matches the value stored in KVM (against my key) then I allow access, else I deny access.
Please suggest if this is achievable and any sample proxy that is using this
Many Thanks again.
Essentially you will want to execute a RaiseFault policy on a condition where the KVM variable matches the query param.
Something like:
<Step> <Name>kvmGetConfig</Name> </Step> <Step> <Name>raiseAccessDenied</Name> <Condition>config.var==request.queryParam.var</Condition> </Step>
The raiseAcessDenied policy provides the details to the user on the fault that occurred as in the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RaiseFault async="false" continueOnError="false" enabled="true" name="raiseAccessDenied"> <DisplayName>raiseAccessDenied</DisplayName> <FaultResponse> <Set> <StatusCode>404</StatusCode> <ReasonPhrase>Resource not found. Value 'var' was incorrect</ReasonPhrase> </Set> </FaultResponse> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </RaiseFault>
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |