啟用 Apigee 營利服務

本頁內容適用於 ApigeeApigee Hybrid

查看 Apigee Edge 說明文件。

如要使用 Apigee 營利功能,您必須先在機構中購買並啟用這項功能。 Apigee 和 Apigee Hybrid 環境都支援 Apigee Monetization。

購買 Apigee Monetization

如要為採用訂閱制的機構購買 Apigee 營利服務,請按照下列步驟操作:

  1. 確認 Apigee 訂閱方案包含 Apigee 營利功能。 請參閱「Apigee 授權」。
  2. 如要購買 Apigee 營利功能,請與 Apigee 銷售團隊聯絡。

在機構中啟用 Apigee 營利服務

如要在現有機構中啟用 Apigee 營利功能,請向下列 API 發出 POST 要求,並在要求主體中傳遞外掛程式設定:

https://apigee.googleapis.com/v1/organizations/$ORG:setAddons

例如:

curl "https://apigee.googleapis.com/v1/organizations/$ORG:setAddons" \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-type: application/json" \
  -d '{
    "addonsConfig": {
      "monetizationConfig": {
          "enabled": "true"
      }
      <Include existing add-on configuration>
    }
  }'

其中 $TOKEN 會設為您的 OAuth 2.0 存取權杖,如「取得 OAuth 2.0 存取權杖」一文所述。如要瞭解本範例使用的 curl 選項,請參閱「使用 curl」。如要瞭解所用環境變數的說明,請參閱「設定 Apigee API 要求的環境變數」。

以下是回應範例,顯示作業正在進行中:

{
  "name": "organizations/$ORG/operations/1ae3ed56-b38f-4cc1-ba33-e7d89557075d",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.apigee.v1.OperationMetadata",
    "operationType": "UPDATE",
    "targetResourceName": "organizations/$ORG",
    "state": "IN_PROGRESS"
  }
}

詳情請參閱「設定機構外掛程式 API」。

查看機構設定檔,確認營利功能已啟用。例如:

curl "https://apigee.googleapis.com/v1/organizations/$ORG" \
  -X GET \
  -H "Authorization: Bearer $TOKEN"

以下是回應範例,顯示營利功能已啟用。

{
    "name": $ORG,
    ...
    "addonsConfig": {
    "monetizationConfig": {
      "enabled": true
    }
  }
}

在機構中停用 Apigee 營利服務

如要在貴機構中停用 Apigee 營利功能,請對下列 API 發出 POST 要求,並在要求主體中傳遞外掛程式設定:

https://apigee.googleapis.com/v1/organizations/$ORG:setAddons

例如:

curl "https://apigee.googleapis.com/v1/organizations/$ORG:setAddons" \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-type: application/json" \
  -d '{
    "addonsConfig": {
      "monetizationConfig": {
          "enabled": "false"
      }
     <Include existing add-on configuration>
    }
  }'

以下是回應範例,顯示作業正在進行中:

{
  "name": "organizations/$ORG/operations/06274ffb-8940-41da-836d-781cba190437",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.apigee.v1.OperationMetadata",
    "operationType": "UPDATE",
    "targetResourceName": "organizations/$ORG",
    "state": "IN_PROGRESS"
  }
}

詳情請參閱「設定機構外掛程式 API」。

查看機構設定檔,確認營利功能已停用。例如:

curl "https://apigee.googleapis.com/v1/organizations/$ORG" \
  -X GET \
  -H "Authorization: Bearer $TOKEN"

以下是回應範例,顯示營利功能已啟用。

{
    "name": $ORG,
    ...
    "addonsConfig": {
    "monetizationConfig": {
      "enabled": false
    }
  }
}

排解啟用 Apigee Monetization 時發生的問題

如果您尚未購買 Apigee 營利功能,但嘗試啟用這項功能,系統會傳回下列錯誤訊息:

{
  "error": {
    "code": 400,
    "message": "failed to validate addons config: [Apigee Monetization] addon(s) are not entitled to the subscription",
    "status": "FAILED_PRECONDITION"
  }
}