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

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

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

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

Node.js

  • आपके पास Business या Enterprise वर्शन वाला 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);
}

main().catch(console.error);

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

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