概要

Alert Center API を使用すると、ドメインに影響するアラートを管理できます。アラートは、Google が検出した潜在的なセキュリティ問題に関する警告です。アラートには次の情報が含まれます。

  • アラートの発信元。
  • アラートの名前。
  • このアラートが発生した時刻。
  • このアラートに関連付けられた特定のデータ。

ドメイン管理者は、Google 管理コンソールからアラートを手動で表示して管理できます。Alert Center API を使用すると、構築したアプリでアラートデータとアラート フィードバックを取得できます。この API では、既存のアラートに新しいアラート フィードバックを作成することもできます。

たとえば、モニタリング アプリで Alert Center API を使用して、ドメインに関する最新のアラートを取得し、優先順位を付けて、組織のメンバーに通知できます。チームがアラートに応答した後、アプリは検出結果に基づいてアラートにフィードバックを添付できます。

Alert Center API を使用する

Alert Center API を使用するには、新しい Cloud Platform プロジェクトを設定して Alert Center API を有効にする必要があります。プロジェクトで API にアクセスする際は、サービス アカウントを使用する必要があります。

前提条件を満たす Cloud プロジェクトがアプリに作成され、適切に承認されると、アラート センター API の REST リクエストを行うことができます。利用可能なクライアント ライブラリを使用すると、API リクエストを簡単に作成できます。

次の例は、API を使用して利用可能なアラートを一覧表示する方法を示しています。

Java

// First, authorize the API and create a client to make requests with.
URL serviceAccountUrl = AuthUtils.class.getResource("/client_secret.json");
GoogleCredentials credentials =  ServiceAccountCredentials
    .fromStream(serviceAccountUrl.openStream())
    .createDelegated("admin@xxxx.com")
    .createScoped(Collections.singleton("https://www.googleapis.com/auth/apps.alerts"));
ApacheHttpTransport transport = new ApacheHttpTransport();
HttpCredentialsAdapter adapter = new HttpCredentialsAdapter(credentials);
AlertCenter alertCenter = new AlertCenter.Builder(transport, new JacksonFactory(), adapter)
    .setApplicationName("Alert Center client")
    .build();

// List alerts in pages, printing each alert discovered.
String pageToken = null;
do {
  ListAlertsResponse listResponse = service.alerts().list().setPageToken(pageToken)
      .setPageSize(20).execute();
  if (listResponse.getAlerts() != null) {
    for (Alert alert : listResponse.getAlerts()) {
      System.out.println(alert);
    }
  }
  pageToken = listResponse.getNextPageToken();
} while (pageToken != null);