Chrome 管理安全性洞察 API 的代码示例

如需了解 API 功能,请参阅 Chrome Management Security Insights 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,则在根 OU 中配置 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"
}

查询网域的概要内容传输摘要

如需检索内容转移的高级摘要,请使用 queryContentTransfers 方法。

请求

  curl -G \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "filter=event_time >= \"2026-05-01T00:00:00Z\" AND event_time <= \"2026-05-02T00:00:00Z\"" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enterprise/securityInsights:queryContentTransfers"

响应

{
  "summaries": [
    {
      "metric": "CONTENT_TRANSFERS_METRIC_TOTAL_SENSITIVE_TRANSFERS",
      "count": "918"
    },
    {
      "metric": "CONTENT_TRANSFERS_METRIC_TOTAL_DOWNLOADS",
      "count": "1537"
    },
    {
      "metric": "CONTENT_TRANSFERS_METRIC_TOTAL_UPLOADS",
      "count": "1532"
    },
    {
      "metric": "CONTENT_TRANSFERS_METRIC_SENSITIVE_UPLOADS",
      "count": "306"
    },
    {
      "metric": "CONTENT_TRANSFERS_METRIC_TOTAL_TRANSFERS",
      "count": "4596"
    },
    {
      "metric": "CONTENT_TRANSFERS_METRIC_SENSITIVE_PRINTS",
      "count": "305"
    },
    {
      "metric": "CONTENT_TRANSFERS_METRIC_SENSITIVE_DOWNLOADS",
      "count": "307"
    },
    {
      "metric": "CONTENT_TRANSFERS_METRIC_TOTAL_PRINTS",
      "count": "1527"
    }
  ]
}

查询包含细分的转移内容摘要

如需查询按维度(例如按 USER)细分的内容转移,请使用 queryContentTransfersBreakdowns 方法。

请求

  curl -G \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "breakdown=USER" \
  --data-urlencode "metric=CONTENT_TRANSFERS_METRIC_TOTAL_TRANSFERS" \
  --data-urlencode "fixedTimeRange=FIXED_TIME_RANGE_FOUR_WEEKS" \
  --data-urlencode "filter=user = \"user1\" AND event_time <= \"2026-05-01T00:00:00Z\"" \
  --data-urlencode "pageSize=5" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enterprise/securityInsights:queryContentTransfersBreakdowns"

响应

{
  "contentTransfersBreakdowns": [
    {
      "user": "user1",
      "summary": {
        "metric": "CONTENT_TRANSFERS_METRIC_TOTAL_TRANSFERS",
        "count": "20"
      }
    }
  ]
}

查询网域的高级网址访问摘要

如需检索可疑网址访问的高级摘要,请使用 queryUrlVisits 方法。

请求

  curl -G \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "filter=event_time >= \"2026-05-01T00:00:00Z\" AND event_time <= \"2026-05-02T00:00:00Z\"" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enterprise/securityInsights:queryUrlVisits"

响应

{
  "summaries": [
    {
      "metric": "URL_VISITS_METRIC_HIGH_RISK_URL_VISITS",
      "count": "286"
    },
    {
      "metric": "URL_VISITS_METRIC_LOW_RISK_URL_VISITS",
      "count": "287"
    },
    {
      "metric": "URL_VISITS_METRIC_TOTAL_SUSPICIOUS_URL_VISITS",
      "count": "859"
    },
    {
      "metric": "URL_VISITS_METRIC_MEDIUM_RISK_URL_VISITS",
      "count": "286"
    }
  ]
}

查询包含细分的网址访问摘要

如需查询按维度细分的网址访问次数(例如按 EVENT_DOMAIN 细分),请使用 queryUrlVisitsBreakdowns 方法。

请求

  curl -G \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "breakdown=EVENT_DOMAIN" \
  --data-urlencode "metric=URL_VISITS_METRIC_TOTAL_SUSPICIOUS_URL_VISITS" \
  --data-urlencode "fixedTimeRange=FIXED_TIME_RANGE_ONE_WEEK" \
  --data-urlencode "filter=event_domain = \"suspicious-domain.com\" AND event_time <= \"2026-05-01T00:00:00Z\"" \
  --data-urlencode "pageSize=5" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enterprise/securityInsights:queryUrlVisitsBreakdowns"

响应

{
  "urlVisitsBreakdowns": [
    {
      "eventDomain": "suspicious-domain.com",
      "summary": {
        "metric": "URL_VISITS_METRIC_TOTAL_SUSPICIOUS_URL_VISITS",
        "count": "132"
      }
    }
  ]
}