Chrome Management Security Insights API 的程式碼範例

如要瞭解 API 功能,請參閱 Chrome 管理安全性深入分析 API

下方顯示的所有要求都會使用下列變數:

  • $TOKEN - OAuth 2 權杖
  • $CUSTOMER - 客戶 ID 或字面值 my_customer

查看網域深入分析資訊的啟用狀態

如要查看網域洞察資料的啟用狀態,請使用 checkEnablementStatus 方法。

要求

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enterprise/securityInsights:checkEnablementStatus"

回應

{
  "insightsState": "INSIGHTS_ENABLED"
}

為網域啟用洞察資料

如要為網域啟用深入分析,請使用 enable 方法。您也可以選擇提供 targetOus,為特定機構單位設定 Chrome 連接器。如果未設定 targetOus,系統會在根機構單位設定 Chrome 連接器。

要求

  curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "targetOus": [
      "/corp/sales",
      "/eng"
    ]
  }' \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enterprise/securityInsights:enable"

回應

{
  "insightsState": "INSIGHTS_ENABLED"
}

停用網域的深入分析資訊

如要停用網域的洞察資料,請使用 disable 方法。

要求

  curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}' \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enterprise/securityInsights:disable"

回應

{
  "insightsState": "INSIGHTS_DISABLED"
}