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

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

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

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

Node.js

  • आपके पास Google Chat का ऐक्सेस हो और आपके पास Google Workspace का Business या Enterprise वर्शन वाला खाता हो.

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

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

  • 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 का एक इंस्टेंस दिखाता है.