節流API可協助您建立、設定和監視節流設定,以限制每秒傳送的事件數。
目前每個組織僅允許一個設定。 必須在生產沙箱上定義設定 (透過標題中的 x-sandbox-name 提供)。
組織層級會套用設定。
當達到 API 設定的限制時,會將更多事件排入佇列,最多 6 小時。 無法修改此值。
方法 | 路徑 | 說明 |
---|---|---|
POST | list/throttlingConfigs | 取得節流設定的清單 |
POST | /throttlingConfigs | 建立節流設定 |
POST | /throttlingConfigs/{uid} /deploy |
部署節流設定 |
POST | /throttlingConfigs/{uid} /undeploy |
取消部署節流設定 |
POST | /throttlingConfigs/{uid} /canDeploy |
檢查是否可以部署節流設定 |
PUT | /throttlingConfigs/{uid} |
更新節流設定 |
GET | /throttlingConfigs/{uid} |
擷取節流設定 |
DELETE | /throttlingConfigs/{uid} |
刪除節流設定 |
以下是節流設定的結構。 name及description屬性為選用。
{
"name": "<given name - free text>",
"description": "<given description - free text>"
"urlPattern": "<endpoint URL - wildcards are allowed>",
"methods": [ "<HTTP method such as GET, POST, PUT>" ],
"maxThroughput": <max call throughput>
}
範例:
{
"name": "throttling-config-external",
"description": "example of throttling config for an external endpoint",
"urlPattern": "https://api.example.org/data/2.5/*",
"methods": ["POST", "PUT"],
"maxThroughput": 4000
}
建立或更新設定時,流程會驗證指定的設定,並傳回以其唯一 ID 識別的驗證狀態,其中一項為:
"ok" or "error"
屬性 maxThroughput、urlPattern及方法為必填。
maxThroughput 值必須在 200-5000 範圍內。
當建立、刪除或部署節流設定時,可能會發生以下錯誤:
<mandatory attribute>
必填錯誤範例
當嘗試在非生產沙箱上建立設定時:
{
"status": 400,
"error": "{\"code\":1463,\"family\":\"INPUT_OUTPUT_ERROR\",\"message\":\"Operation not allowed on throttling config: non prod sandbox\",\"service\":\"vyg-authoring-api\",\"version\":\"ed87515\",\"context\":\"com.adobe.voyager.service.authoring.restapis.v1_0.ThrottlingConfigService:384\",\"schema\":\"throttlingConfigs$ui-tests\"}",
"requestId": "5sgnAYXs8mpswwjAFEIaAU2faQYbtyHc"
}
如果給定的沙箱不存在:
{
"status": 500,
"error": "{\"code\":4000,\"family\":\"INTERNAL_ERROR\",\"message\":\"INTERNAL ERROR\",\"service\":\"vyg-authoring-api\",\"version\":\"ed87515\",\"context\":\"com.adobe.voyager.common.exceptions.ApiErrorException:43\"}",
"requestId": "04ZJ4e5ki4bYs3lfO17a7hovRGewjvdK"
}
當嘗試建立其他設定時:
{
"status": 400,
"error": "{\"code\":1465,\"family\":\"INPUT_OUTPUT_ERROR\",\"message\":\"Can't create throttling config: only one config allowed per org\",\"service\":\"vyg-authoring-api\",\"version\":\"ed87515\",\"context\":\"com.adobe.voyager.service.authoring.restapis.v1_0.ThrottlingConfigService:108\",\"schema\":\"throttlingConfigs$prod\"}",
"requestId": "A7ezT8JhOQT4WIAf1Fv7K2wCDA8281qM"
}
為協助您進行測試和設定,可在此處取得 Postman 集合。
此 Postman 集合已設定為共用透過 Adobe I/O 主控台的整合產生的 Postman 變數集合 > 試用 > 下載 Postman,會產生包含選取整合值的 Postman 環境檔案。
一旦下載並上傳至 Postman,您需要新增三個變數:{JO_HOST}
、{BASE_PATH}
以及{SANDBOX_NAME}
。
{JO_HOST}
: Journey Orchestration閘道 URL{BASE_PATH}
:API 的進入點。 值為「/authoring」{SANDBOX_NAME}
:標題 x-sandbox-name (例如,'prod'),此名稱對應於將進行 API 操作的沙箱名稱。如需詳細資訊,請參閱沙箱概觀。您將在下節找到用於執行使用案例的 Rest API 呼叫排序清單。
使用案例 n°1:建立和部署新的節流設定
使用案例 n°2:更新並部署尚未部署的節流設定
使用案例 n°3:取消部署並刪除已部署的節流設定
使用案例 n°4:刪除已部署的節流設定
在僅一個 API 呼叫,您可以使用 forceDelete 參數來取消部署和刪除設定。
使用案例 n°5:更新已部署的節流設定
更新前不需要取消部署設定
當取消部署設定時,會在執行階段層級將其標示為非活動狀態,且 24 小時內會繼續處理擱置事件。 然後,在執行階段服務將其刪除。
取消部署設定後,可以更新和重新部署設定。 這將建立新的執行階段設定,將在即將執行的動作中考慮該設定。
當更新已部署的設定時,會立即考慮新值。自動調整基礎系統資源。 與取消部署然後重新部署設定相比,這是最佳選擇。
建立 - POST
{
"canDeploy": {
"validationStatus": "ok"
},
"createdElement": {
"name": "throttling-config-external",
"description": "example of throttling config for an external endpoint",
"urlPattern": "https://api.example.org/data/2.5/*",
"methods": [
"PUT",
"POST"
],
"maxThroughput": 4000,
"orgId": "AC202A3A5F615BD30A495FDE@AdobeOrg",
"sandboxId": "8872a010-f91e-11ea-895c-11ef8f98ba52",
"sandboxName": "prod",
"uid": "043a1aea-2dfd-4965-b93a-cb9a1eced0e6",
"metadata": {
"createdBy": "dacce1c3-d08b-4862-b434-2a4449c7e642@techacct.adobe.com",
"createdById": "309F2A46640B0B300A495C83@techacct.adobe.com",
"lastModifiedBy": "dacce1c3-d08b-4862-b434-2a4449c7e642@techacct.adobe.com",
"lastModifiedById": "309F2A46640B0B300A495C83@techacct.adobe.com",
"createdAt": "2023-03-22T10:48:16.099647Z",
"lastModifiedAt": "2023-03-22T10:48:16.099647Z"
},
"state": "created",
"authoringFormatVersion": "1.0"
},
"uid": "043a1aea-2dfd-4965-b93a-cb9a1eced0e6",
"uri": "/voyager/apis/throttlingConfigs/043a1aea-2dfd-4965-b93a-cb9a1eced0e6",
"resStatus": "created"
}
更新 - PUT
{
"updatedElement": {
"_id": "043a1aea-2dfd-4965-b93a-cb9a1eced0e6_8872a010-f91e-11ea-895c-11ef8f98ba52",
"name": "throttling-config-external -- optional",
"description": "example of throttling config for an external endpoint -- optional",
"urlPattern": "https://api.example.org/data/2.5/*",
"methods": [
"POST"
],
"maxThroughput": 5000,
"orgId": "AC202A3A5F615BD30A495FDE@AdobeOrg",
"sandboxId": "8872a010-f91e-11ea-895c-11ef8f98ba52",
"sandboxName": "prod",
"uid": "043a1aea-2dfd-4965-b93a-cb9a1eced0e6",
"metadata": {
"createdBy": "dacce1c3-d08b-4862-b434-2a4449c7e642@techacct.adobe.com",
"createdById": "309F2A46640B0B300A495C83@techacct.adobe.com",
"lastModifiedBy": "dacce1c3-d08b-4862-b434-2a4449c7e642@techacct.adobe.com",
"lastModifiedById": "309F2A46640B0B300A495C83@techacct.adobe.com",
"createdAt": "2023-03-22T10:48:16.099647Z",
"lastModifiedAt": "2023-03-22T11:39:14.212983Z"
},
"state": "updated",
"authoringFormatVersion": "1.0",
"hasBeenDeployed": false
},
"uid": "043a1aea-2dfd-4965-b93a-cb9a1eced0e6",
"uri": "/voyager/apis/throttlingConfigs/043a1aea-2dfd-4965-b93a-cb9a1eced0e6",
"resStatus": "updated",
"canDeploy": {
"validationStatus": "ok"
}
}
讀取 (更新後) - GET
{
"result": {
"_id": "043a1aea-2dfd-4965-b93a-cb9a1eced0e6_8872a010-f91e-11ea-895c-11ef8f98ba52",
"name": "throttling-config-external -- optional",
"description": "example of throttling config for an external endpoint -- optional",
"urlPattern": "https://api.example.org/data/2.5/*",
"methods": [
"POST"
],
"maxThroughput": 5000,
"orgId": "AC202A3A5F615BD30A495FDE@AdobeOrg",
"sandboxId": "8872a010-f91e-11ea-895c-11ef8f98ba52",
"sandboxName": "prod",
"uid": "043a1aea-2dfd-4965-b93a-cb9a1eced0e6",
"metadata": {
"createdBy": "dacce1c3-d08b-4862-b434-2a4449c7e642@techacct.adobe.com",
"createdById": "309F2A46640B0B300A495C83@techacct.adobe.com",
"lastModifiedBy": "dacce1c3-d08b-4862-b434-2a4449c7e642@techacct.adobe.com",
"lastModifiedById": "309F2A46640B0B300A495C83@techacct.adobe.com",
"createdAt": "2023-03-22T10:48:16.099647Z",
"lastModifiedAt": "2023-03-22T11:39:14.212983Z"
},
"state": "updated",
"authoringFormatVersion": "1.0",
"hasBeenDeployed": false
}
}
讀取 (部署後) - GET
{
"result": {
"_id": "043a1aea-2dfd-4965-b93a-cb9a1eced0e6_8872a010-f91e-11ea-895c-11ef8f98ba52",
"orgId": "AC202A3A5F615BD30A495FDE@AdobeOrg",
"sandboxId": "8872a010-f91e-11ea-895c-11ef8f98ba52",
"sandboxName": "prod",
"uid": "043a1aea-2dfd-4965-b93a-cb9a1eced0e6",
"urlPattern": "https://api.example.org/data/2.5/*",
"methods": [
"POST"
],
"maxThroughput": 5000,
"authoringFormatVersion": "1.0",
"name": "throttling-config-external -- optional",
"description": "example of throttling config for an external endpoint -- optional",
"version": "1.0",
"state": "deployed",
"metadata": {
"createdBy": "dacce1c3-d08b-4862-b434-2a4449c7e642@techacct.adobe.com",
"createdById": "309F2A46640B0B300A495C83@techacct.adobe.com",
"createdAt": "2023-03-22T10:48:16.099647Z",
"lastModifiedBy": "dacce1c3-d08b-4862-b434-2a4449c7e642@techacct.adobe.com",
"lastModifiedById": "309F2A46640B0B300A495C83@techacct.adobe.com",
"lastModifiedAt": "2023-03-22T11:39:14.212983Z",
"lastDeployedBy": "dacce1c3-d08b-4862-b434-2a4449c7e642@techacct.adobe.com",
"lastDeployedById": "309F2A46640B0B300A495C83@techacct.adobe.com",
"lastDeployedAt": "2023-03-22T11:46:07.532648Z"
},
"hasBeenDeployed": true
}
}