啟用 Apigee 營利服務

本頁適用於 ApigeeApigee Hybrid

查看 Apigee Edge 說明文件。

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

購買 Apigee 營利服務

如要為訂閱制機構購買 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 營利服務啟用問題

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

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