API Bazlı Kısıtlama (policy-api-based-throttling tipi)
Parametreler
Parametre | Tip | Zorunlu | Varsayılan Değer | Açıklama | Kurallar |
---|---|---|---|---|---|
name | String | Evet | - | Politika adı | API Proxy içinde benzersiz olmalı |
targetVariableForIdentity | VariableDTO | Hayır | - | Throttling takibi için kullanılacak kimlik değişkeni | Bkz. |
messageCountForInterval | Integer | Evet | - | Belirtilen zaman aralığında izin verilen maksimum istek sayısı | 0'dan büyük olmalı |
throttlingInterval | EnumThrottleTimeInterval | Evet | - | Throttling zaman aralığı | - |
cacheConnectionTimeoutInSeconds | Integer | Hayır | 3 | Önbellek bağlantı zaman aşımı (saniye) | 0'dan büyük olmalı |
cacheErrorHandlingType | Enum | Hayır | FAIL | Önbellek hatası durumunda yapılacak işlem | - |
detailList | Array | Hayır | - | Her hedef (örn. kullanıcı, IP) için özel throttling sınırları tanımlanır | Bir veya birden fazla throttling sınırları tanımlanır. |
throttlingInterval değerleri
Değer | Açıklama |
---|---|
ONE_SECOND | Saniye başına istek sınırı |
ONE_MINUTE | Dakika başına istek sınırı |
cacheErrorHandlingType değerleri
Değer | Açıklama |
---|---|
FAIL | Önbellek hatası durumunda isteği reddet |
CONTINUE | Önbellek hatası durumunda isteğe izin ver |
detailList Dizisine Eklenebilecek Değerler
Parametre | Tip | Zorunlu | Varsayılan Değer | Açıklama | Kurallar |
---|---|---|---|---|---|
targetValue | String | Hayır | - | Hedef Değeri | - |
regexExpression | Bool | Hayır | false | Regex İfadesi | - |
messageCountForInterval | Integer | Hayır | - | Throttling Zaman Aralığı için Mesaj Sayısı | 0'dan büyük olmalı |
intervalPeriodLength | Integer | Hayır | - | Throttling Zaman Aralığı | 0'dan büyük olmalı |
throttlingInterval | Enum | Hayır | - | Throttling Zaman Birimi | - |
Örnek JSON Yapıları
1. IP Bazlı Saniyelik Throttling
{
"operationMetadata" : {
"targetScope" : "ALL",
"targetPipeline" : "REQUEST",
"deploy" : true,
"deployTargetEnvironmentNameList": [
"test", "prod"
],
"order" : 1
},
"policy" : {
"type" : "policy-api-based-throttling",
"name" : "SaniyelikIpThrottling",
"messageCountForInterval" : 10,
"throttlingInterval" : "ONE_SECOND",
"cacheConnectionTimeoutInSeconds" : 5,
"cacheErrorHandlingType" : "FAIL",
"targetVariableForIdentity" : {
"name" : "clientIp",
"type" : "CONTEXT_VALUES",
"contextValue" : "REQUEST_REMOTE_ADDRESS",
"description" : "İstemci IP adresi"
}
}
}
CODE
2. IP Bazlı Saniyelik Throttling + Kullanıcı IP Bazlı Saniyelik ve Dakikalık Kota
{
"operationMetadata" : {
"targetScope" : "ALL",
"targetPipeline" : "REQUEST",
"deploy" : true,
"deployTargetEnvironmentNameList": [
"test", "prod"
],
"order" : 1
},
"policy" : {
"type" : "policy-api-based-throttling",
"name" : "SaniyelikIpThrottling",
"messageCountForInterval" : 10,
"throttlingInterval" : "ONE_SECOND",
"cacheConnectionTimeoutInSeconds" : 5,
"cacheErrorHandlingType" : "FAIL",
"targetVariableForIdentity" : {
"name" : "clientIp",
"type" : "CONTEXT_VALUES",
"contextValue" : "REQUEST_REMOTE_ADDRESS",
"description" : "İstemci IP adresi"
},
"detailList": [
{
"targetValue": "<IP>",
"regexExpression": false,
"messageCountForInterval": 20,
"intervalPeriodLength": 1,
"quotaInterval": "ONE_SECOND"
},
{
"targetValue": "10.0.0.*",
"regexExpression": true,
"messageCountForInterval": 5,
"intervalPeriodLength": 2,
"quotaInterval": "ONE_MINUTE"
}
]
}
}
CODE
3. Dakika Bazlı Throttling
{
"operationMetadata" : {
"targetScope" : "ENDPOINT",
"targetEndpoint" : "/api/v1/transactions",
"targetEndpointHTTPMethod" : "POST",
"targetPipeline" : "REQUEST",
"deploy" : true,
"deployTargetEnvironmentNameList": [
"test", "prod"
],
"order" : 1
},
"policy" : {
"type" : "policy-api-based-throttling",
"name" : "DakikalikApiKeyThrottling",
"messageCountForInterval" : 60,
"throttlingInterval" : "ONE_MINUTE",
"cacheConnectionTimeoutInSeconds" : 3,
"cacheErrorHandlingType" : "PASS",
"targetVariableForIdentity" : {
"name" : "apiKey",
"type" : "HEADER",
"headerName" : "X-API-KEY",
"description" : "API Anahtarı"
}
}
}
CODE