Chrome 管理安全性洞察 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"
}