概要

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 プロジェクトがアプリに配置され、適切に承認されると、Alert Center 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);