API Bazlı Kota (policy-api-based-quota tipi)
Parametreler
Parametre | Tip | Zorunlu | Varsayılan Değer | Açıklama | Kurallar |
---|---|---|---|---|---|
name | String | Evet | - | Politika adı | API Proxy içinde benzersiz olmalı |
targetVariableForIdentity | Variable Nesnesi | Hayır | - | Kota 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ı |
quotaInterval | Enum | Evet | - | Kota 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 kota sınırları tanımlanır | Bir veya birden fazla kota sınırları tanımlanır. |
quotaInterval Enum Değerleri
Değer | Açıklama |
---|---|
ONE_DAY | Gün başına kota |
ONE_WEEK | Hafta başına kota |
ONE_MONTH | Ay başına kota |
cacheErrorHandlingType Enum Değerleri
Değer | Açıklama |
---|---|
FAIL | Önbellek hatası durumunda isteği reddet |
PASS | Ö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 | - | Kota Zaman Aralığı için Mesaj Sayısı | 0'dan büyük olmalı |
intervalPeriodLength | Integer | Hayır | - | Kota Zaman Aralığı | 0'dan büyük olmalı |
quotaInterval | Enum | Hayır | - | Kota Zaman Birimi | - |
Örnek JSON Yapıları
1. IP Bazlı Saatlik Kota
{
"operationMetadata" : {
"targetScope" : "ALL",
"targetPipeline" : "REQUEST",
"deploy" : true,
"deployTargetEnvironmentNameList": [
"test", "prod"
],
"order" : 1
},
"policy" : {
"type" : "policy-api-based-quota",
"name" : "GunlukIpKotasi",
"messageCountForInterval" : 1000,
"quotaInterval" : "ONE_HOUR",
"cacheConnectionTimeoutInSeconds" : 5,
"cacheErrorHandlingType" : "FAIL",
"targetVariableForIdentity" : {
"name" : "clientIp",
"type" : "CONTEXT_VALUES",
"contextValue" : "REQUEST_REMOTE_ADDRESS",
"description" : "İstemci IP adresi"
}
}
}
CODE
2. IP Bazlı Saatlik Kota + Kullanıcı IP Bazlı Günlük ve Saatlik Kota
{
"operationMetadata" : {
"targetScope" : "ALL",
"targetPipeline" : "REQUEST",
"deploy" : true,
"deployTargetEnvironmentNameList": [
"test", "prod"
],
"order" : 1
},
"policy" : {
"type" : "policy-api-based-quota",
"name" : "GunlukIpKotasi",
"messageCountForInterval" : 1000,
"quotaInterval" : "ONE_HOUR",
"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_DAY"
},
{
"targetValue": "10.0.0.*",
"regexExpression": true,
"messageCountForInterval": 5,
"intervalPeriodLength": 2,
"quotaInterval": "ONE_HOUR"
}
]
}
}
CODE
3. API Key Bazlı Günlük Kota + Kullanıcı API Key Bazlı Saatlik Kota
{
"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. Kullanıcı Id Bazlı Aylık Kota
{
"operationMetadata" : {
"targetScope" : "ALL",
"targetPipeline" : "REQUEST",
"deploy" : true,
"deployTargetEnvironmentNameList": [
"test", "prod"
],
"order" : 1
},
"policy" : {
"type" : "policy-api-based-quota",
"name" : "AylikKullaniciKotasi",
"messageCountForInterval" : 50000,
"quotaInterval" : "ONE_MONTH",
"targetVariableForIdentity" : {
"name" : "userId",
"type" : "BODY",
"targetContentType" : "JSON",
"jsonPathValue" : "$.user.id",
"description" : "Kullanıcı ID"
}
}
}
CODE