Peak - off peak time based upon the system time and country

Hello,

i was parsing through the Quota policy document to understand the peak - off peak concept . based upon the below example. this relies on the information passed in query param to decide which limit should be added to the proxy.

My use case is : as an admin, i don't want user to pass on any information related to the rate limit rather I want to give put rate limit as a restriction to save my system from abuse. hence i want to offer a better limit during daytime in a country by giving then 5 transactions per second limit. but during off business hours, i want to give only 1TPS limit to the user.

i want to understand how can i make the below policy smart enough to read system time, country code from the user's custom attribute, and then after converting the time to local time - decide whether it is peak or non peak for that country.

<Allowcount="2000"countRef="verifyapikey.VerifyAPIKey.apiproduct.developer.quota.limit"/><Allow><Classref="request.queryparam.time_variable"><Allowclass="peak_time"count="5000"/><Allowclass="off_peak_time"count="1000"/></Class></Allow>
0 1 177
1 REPLY 1

Not applicable

what you have to do is,

put the peak time and location in a product or app custom attribute.

fetch that in proxy and decide the class in a javascript. refer that class in the quota policy and

if (time > 20 && time < 24 && location == "USA")
{
    time-slot = "peak";
} 

else
{
   time-slot = "non-peak";
}
  <Allow>
    <Class ref="time-slot">
      <Allow class="peak" count="100"/>
      <Allow class="non-peak" count="1" />
    </Class>
  </Allow>