किसी उपयोगकर्ता के स्पेस की सूचना सेटिंग अपडेट करना

इस गाइड में, Google Chat API के SpaceNotificationSetting संसाधन पर patch() तरीके का इस्तेमाल करके, किसी उपयोगकर्ता की स्पेस सूचना सेटिंग अपडेट करने का तरीका बताया गया है.

SpaceNotificationSetting संसाधन एक सिंगलटन संसाधन है. यह किसी खास उपयोगकर्ता की स्पेस सूचना सेटिंग के बारे में जानकारी दिखाता है.

ज़रूरी शर्तें

Node.js

  • कारोबारी या एंटरप्राइज़ Google Workspace खाता, जिसके पास Google Chat का ऐक्सेस हो.

कॉल करने वाले उपयोगकर्ता की स्पेस सूचना सेटिंग अपडेट करना

किसी उपयोगकर्ता की स्पेस सूचना सेटिंग अपडेट करने के लिए, अपने अनुरोध में यह जानकारी शामिल करें:

  • chat.users.spacesettings अनुमति पाने का लिंक तय करें.
  • UpdateSpaceNotificationSetting() तरीके को कॉल करें. साथ ही, UpdateSpaceNotificationSetting अनुरोध पास करें, ताकि सूचना सेटिंग में किए गए बदलाव शामिल किए जा सकें. अनुरोध में यह जानकारी शामिल होती है:
    • spaceNotificationSetting इन प्रॉपर्टी के साथ:
      • name प्रॉपर्टी से यह तय होता है कि किस स्पेस सूचना सेटिंग को अपडेट करना है. इसमें उपयोगकर्ता का आईडी या एलियस और स्पेस का आईडी शामिल होता है. स्पेस सूचना सेटिंग को अपडेट करने की सुविधा से, सिर्फ़ कॉल करने वाले उपयोगकर्ता की सूचना सेटिंग को अपडेट किया जा सकता है. इसे इनमें से कोई एक सेटिंग करके तय किया जा सकता है:
        • me एलियस. उदाहरण के लिए, users/me/spaces/SPACE/spaceNotificationSetting.
        • कॉल करने वाले उपयोगकर्ता का Workspace ईमेल पता. उदाहरण के लिए, users/user@example.com/spaces/SPACE/spaceNotificationSetting.
        • कॉल करने वाले उपयोगकर्ता का आईडी. उदाहरण के लिए, users/USER/spaces/SPACE/spaceNotificationSetting.
      • notificationSetting: सूचना का लेवल सेट करता है. जैसे, ALL, OFF.
      • muteSetting: म्यूट करने की सेटिंग को चालू या बंद करता है. इसकी वैल्यू MUTED या UNMUTED हो सकती है.
    • updateMask: अपडेट किए जाने वाले फ़ील्ड सेट करता है. इसमें notification_setting, mute_setting शामिल हो सकती हैं.

यहां दिए गए उदाहरण में, कॉल करने वाले उपयोगकर्ता की स्पेस सूचना सेटिंग अपडेट की गई है:

Node.js

chat/client-libraries/cloud/update-space-notification-setting-user-cred.js
import {createClientWithUserCredentials} from './authentication-utils.js';

const USER_AUTH_OAUTH_SCOPES = [
  'https://www.googleapis.com/auth/chat.users.spacesettings',
];

// This sample shows how to update the space notification setting for the
// calling user
async function main() {
  // Create a client
  const chatClient = await createClientWithUserCredentials(
    USER_AUTH_OAUTH_SCOPES,
  );

  // Initialize request argument(s), replace the SPACE_NAME with an actual space
  // name.
  const request = {
    spaceNotificationSetting: {
      name: 'users/me/spaces/SPACE_NAME/spaceNotificationSetting',
      notificationSetting: 'ALL',
      muteSetting: 'UNMUTED',
    },
    updateMask: {paths: ['notification_setting', 'mute_setting']},
  };

  // Make the request
  const response = await chatClient.updateSpaceNotificationSetting(request);

  // Handle the response
  console.log(response);
}

await main();

इस सैंपल को चलाने के लिए, SPACE_NAME को स्पेस के name से मिले आईडी से बदलें. `ListSpaces()` तरीके को कॉल करके या स्पेस के यूआरएल से आईडी पाया जा सकता है.ListSpaces()

Google Chat API, तय की गई स्पेस सूचना सेटिंग को अपडेट करता है और an instance of SpaceNotificationSetting दिखाता है.