Parameters

Parameter

Type

Required

Default Value

Description

Rules

nameStringYes-Policy name

API must be unique in Proxy

targetVariableForIdentityVariable ObjectNo-Identity variable to be used for quota tracking
messageCountForIntervalIntegerYes-Maximum number of requests allowed in the specified time intervalMust be greater than 0
quotaIntervalEnum Yes-Quota time interval-
cacheConnectionTimeoutInSecondsIntegerNo3Cache connection timeout (seconds)Must be greater than 0
cacheErrorHandlingTypeEnumNoFAILAction to be taken in case of cache error-

detailList

Array

No

-

Specific quota limits are defined for each destination (e.g. user, IP)

One or more quota limits are defined.

quotaInterval Enum Values

Value

Description

ONE_DAYQuota per day
ONE_WEEKQuota per wek
ONE_MONTHQuota per month 

Value

Descriptions

FAILDeny request in case of cache error
PASSAllow request in case of cache error

Values that can be added to detailList Array

ParameterTypeRequiredDefault ValueDescriptionRules

targetValue

String

No

-

Target Value

-

regexExpression

Bool

No

false

Regex Expression

-

messageCountForInterval

Integer

No

-

Number of Messages for Quota Time Interval

Must be greater than 0

intervalPeriodLength

Integer

No

-

Quota Time Interval

Must be greater than 0

quotaInterval

Enum

No

-

Quota Time Interval

-

Example Json Structures

1. IP Based Hourly Quota

{
  "operationMetadata" : {
    "targetScope" : "ALL",
    "targetPipeline" : "REQUEST",
    "deploy" : true,
    "deployTargetEnvironmentNameList": [
      "test", "prod"
    ],
    "order" : 1
  },
  "policy" : {
    "type" : "policy-api-based-quota",
    "name" : "DailyIpKotasi",
    "messageCountForInterval" : 1000,
    "quotaInterval" : "ONE_DAY",
    "cacheConnectionTimeoutInSeconds" : 5,
    "cacheErrorHandlingType" : "FAIL",
    "targetVariableForIdentity" : {
      "name" : "clientIp",
      "type" : "CONTEXT_VALUES",
      "contextValue" : "REQUEST_REMOTE_ADDRESS",
      "description" : "Client IP address"
    }
  }
}
CODE

2. IP Based Hourly Quota + User IP Based Daily and Hourly Quota

{
  "operationMetadata" : {
    "targetScope" : "ALL",
    "targetPipeline" : "REQUEST",
    "deploy" : true,
    "deployTargetEnvironmentNameList": [
      "test", "prod"
    ],
    "order" : 1
  },
  "policy" : {
    "type" : "policy-api-based-quota",
    "name" : "DailyIpKotasi",
    "messageCountForInterval" : 1000,
    "quotaInterval" : "ONE_DAY",
    "cacheConnectionTimeoutInSeconds" : 5,
    "cacheErrorHandlingType" : "FAIL",
    "targetVariableForIdentity" : {
      "name" : "clientIp",
      "type" : "CONTEXT_VALUES",
      "contextValue" : "REQUEST_REMOTE_ADDRESS",
      "description" : "Client IP address"
    },
    "detailList": [
      {
        "targetValue": "<IP>",
        "regexExpression": false,
        "messageCountForInterval": 20,
        "intervalPeriodLength": 1,
        "quotaInterval": "ONE_DAY"
      },
      {
        "targetValue": "10.0.0.*",
        "regexExpression": true,
        "messageCountForInterval": 5,
        "intervalPeriodLength": 2,
        "quotaInterval": "ONE_HOUR"
      }
    ]
  }
}
CODE

3. API Key Based Daily Quota + User API Key Based Hourly Quota

{
  "operationMetadata" : {
    "targetScope" : "ENDPOINT",
    "targetEndpoint" : "/api/v1/islemler",
    "targetEndpointHTTPMethod" : "POST",
    "targetPipeline" : "REQUEST",
    "deploy" : true,
	"deployTargetEnvironmentNameList": [
      "test", "prod"
    ], 
    "order" : 1
  },
  "policy" : {
	"type" : "policy-api-based-quota",
    "name" : "GunlukApiKeyKotasi",
    "messageCountForInterval" : 10000,
    "quotaInterval" : "ONE_DAY",
    "cacheConnectionTimeoutInSeconds" : 3,
    "cacheErrorHandlingType" : "PASS",
    "targetVariableForIdentity" : {
      "name" : "apiKey",
      "type" : "HEADER",
      "headerName" : "X-API-KEY",
      "description" : "API Anahtarı"
    },
	"detailList": [
      {
        "targetValue": "<API_KEY>",
        "regexExpression": false,
        "messageCountForInterval": 20,
        "intervalPeriodLength": 1,
        "quotaInterval": "ONE_HOUR"
      },
    ]   
	}
}
CODE

4. User Id Based Monthly Quota

{
  "operationMetadata" : {
    "targetScope" : "ALL",
    "targetPipeline" : "REQUEST",
    "deploy" : true,
    "deployTargetEnvironmentNameList": [
      "test", "prod"
    ],
    "order" : 1
  },
  "policy" : {    
    "type" : "policy-api-based-quota",
    "name" : "MonthlyUserLimit",
    "messageCountForInterval" : 50000,
    "quotaInterval" : "ONE_MONTH",
    "targetVariableForIdentity" : {
      "name" : "userId",
      "type" : "BODY",
      "targetContentType" : "JSON",
      "jsonPathValue" : "$.user.id",
      "description" : "User ID"
    }
  }
}
CODE