खास जानकारी

Alert Center API की मदद से, अपने डोमेन पर असर डालने वाली चेतावनी मैनेज की जा सकती हैं. चेतावनी, सुरक्षा से जुड़ी किसी संभावित समस्या के बारे में दी जाती है. इस समस्या का पता Google ने लगाया है. चेतावनी में यह जानकारी शामिल होती है:

  • वह सोर्स जिससे यह सूचना जनरेट हुई है.
  • सूचना का नाम.
  • इस सूचना के जनरेट होने का समय.
  • इस सूचना से जुड़ा खास डेटा.

डोमेन एडमिन, Google Admin console में जाकर, सूचनाओं को मैन्युअल तरीके से देख और मैनेज कर सकते हैं. सूचना केंद्र एपीआई की मदद से, बनाए गए ऐप्लिकेशन सूचनाओं का डेटा और सूचनाओं के बारे में सुझाव पा सकते हैं. एपीआई, मौजूदा सूचनाओं के लिए नई सूचनाएं भी बना सकता है.

उदाहरण के लिए, मॉनिटरिंग करने वाला कोई ऐप्लिकेशन, Alert Center API का इस्तेमाल करके किसी डोमेन के लिए सबसे नई सूचनाएं पा सकता है. साथ ही, उन्हें प्राथमिकता दे सकता है. इसके बाद, वह आपके संगठन के सदस्यों को सूचनाएं भेज सकता है. आपकी टीम की ओर से सूचना का जवाब देने के बाद, ऐप्लिकेशन अपनी जांच के आधार पर सूचना में सुझाव या राय जोड़ सकता है.

Alert Center API का इस्तेमाल करना

Alert Center API का इस्तेमाल करने से पहले, आपको नया Cloud Platform प्रोजेक्ट सेट अप करना होगा और Alert Center API चालू करना होगा. एपीआई को ऐक्सेस करते समय, आपके प्रोजेक्ट को सेवा खाते का इस्तेमाल करना होगा.

जब आपके ऐप्लिकेशन के पास ज़रूरी शर्तों को पूरा करने वाला Cloud प्रोजेक्ट होगा और उसे ठीक से अनुमति मिल जाएगी, तब वह सूचना केंद्र के एपीआई के REST अनुरोध कर पाएगा. उपलब्ध क्लाइंट लाइब्रेरी का इस्तेमाल करके, एपीआई अनुरोध आसानी से किए जा सकते हैं.

यहां दिए गए उदाहरण में, एपीआई का इस्तेमाल करके उपलब्ध सूचनाओं को दिखाने का तरीका बताया गया है:

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);