একটি Google চ্যাট স্পেসে একটি ব্যবহারকারীর সদস্যতা আপডেট করুন, একটি Google চ্যাট স্পেসে একটি ব্যবহারকারীর সদস্যতা আপডেট করুন

এই নির্দেশিকাটি ব্যাখ্যা করে যে কীভাবে Google Chat API-এর membership সংস্থানে patch পদ্ধতি ব্যবহার করে সদস্যতা সম্পর্কে গুণাবলী পরিবর্তন করতে হয়, যেমন একজন স্পেস মেম্বারকে স্পেস ম্যানেজারে পরিবর্তন করা বা স্পেস ম্যানেজারকে একজন স্পেস সদস্যে পরিবর্তন করা।

Membership রিসোর্স প্রতিনিধিত্ব করে যে একজন মানব ব্যবহারকারী বা Google চ্যাট অ্যাপকে আমন্ত্রণ জানানো হয়েছে কিনা, এর অংশ বা কোনো স্থান থেকে অনুপস্থিত।

পাইথন

  • পাইথন 3.6 বা তার বেশি
  • পাইপ প্যাকেজ ম্যানেজমেন্ট টুল
  • পাইথনের জন্য সর্বশেষ Google ক্লায়েন্ট লাইব্রেরি। এগুলি ইনস্টল বা আপডেট করতে, আপনার কমান্ড-লাইন ইন্টারফেসে নিম্নলিখিত কমান্ডটি চালান:

    pip3 install --upgrade google-api-python-client google-auth-oauthlib
    
  • Google Chat API সক্ষম এবং কনফিগার করা একটি Google ক্লাউড প্রকল্প। ধাপগুলির জন্য, একটি Google Chat অ্যাপ তৈরি করুন দেখুন।
  • চ্যাট অ্যাপের জন্য অনুমোদন কনফিগার করা হয়েছে। একটি সদস্যপদ আপডেট করার জন্য chat.memberships অনুমোদনের সুযোগের সাথে ব্যবহারকারীর প্রমাণীকরণ প্রয়োজন, অথবা, যদি Chat-এ ডেটা আমদানি করা হয় , chat.import অনুমোদনের সুযোগ।

Node.js

  • Node.js এবং npm
  • Node.js-এর জন্য সর্বশেষ Google ক্লায়েন্ট লাইব্রেরি। এগুলি ইনস্টল করতে, আপনার কমান্ড-লাইন ইন্টারফেসে নিম্নলিখিত কমান্ডটি চালান:

    npm install @google-cloud/local-auth @googleapis/chat
    
  • Google Chat API সক্ষম এবং কনফিগার করা একটি Google ক্লাউড প্রকল্প। ধাপগুলির জন্য, একটি Google Chat অ্যাপ তৈরি করুন দেখুন।
  • চ্যাট অ্যাপের জন্য অনুমোদন কনফিগার করা হয়েছে। একটি সদস্যপদ আপডেট করার জন্য chat.memberships অনুমোদনের সুযোগের সাথে ব্যবহারকারীর প্রমাণীকরণ প্রয়োজন, অথবা, যদি Chat-এ ডেটা আমদানি করা হয় , chat.import অনুমোদনের সুযোগ।

অ্যাপস স্ক্রিপ্ট

একটি সদস্যপদ আপডেট করুন

একটি স্থান সদস্যতা আপডেট করতে, আপনার অনুরোধে নিম্নলিখিত পাস করুন:

  • chat.memberships অনুমোদনের সুযোগ নির্দিষ্ট করুন।
  • Membership রিসোর্সে patch মেথড কল করুন এবং আপডেট করার জন্য মেম্বারশিপের name পাস করুন, সেইসাথে updateMask এবং একটি body যা আপডেট করা মেম্বারশিপ অ্যাট্রিবিউট নির্দিষ্ট করে।
  • updateMask আপডেট করার জন্য সদস্যতার দিকগুলি নির্দিষ্ট করে এবং নিম্নলিখিতগুলি অন্তর্ভুক্ত করে:
    • role : একটি চ্যাট স্পেসের মধ্যে ব্যবহারকারীর ভূমিকা, যা স্পেসে তাদের অনুমোদিত ক্রিয়াগুলি নির্ধারণ করে৷ সম্ভাব্য মান হল:
      • ROLE_MEMBER : স্থানের একজন সদস্য। ব্যবহারকারীর মৌলিক অনুমতি রয়েছে, যেমন স্পেসে বার্তা পাঠানো। 1:1 এবং নামহীন গোষ্ঠী কথোপকথনে, প্রত্যেকেরই এই ভূমিকা রয়েছে৷
      • ROLE_MANAGER : একজন স্পেস ম্যানেজার। ব্যবহারকারীর কাছে সমস্ত মৌলিক অনুমতি এবং প্রশাসনিক অনুমতি রয়েছে যা তাদের স্থান পরিচালনা করতে দেয়, যেমন সদস্য যোগ করা বা সরানো। শুধুমাত্র স্পেসগুলিতে সমর্থিত যেখানে spaceType হল SPACE (নামযুক্ত স্থান)।

একজন নিয়মিত স্পেস সদস্যকে স্পেস ম্যানেজার করুন

নিম্নোক্ত উদাহরণটি একটি নিয়মিত স্পেস সদস্যকে একটি স্পেস ম্যানেজার করে ROLE_MANAGER হিসাবে role নির্দিষ্ট body যা আপডেট করা সদস্যতা বৈশিষ্ট্যগুলি নির্দিষ্ট করে:

পাইথন

  1. আপনার কাজের ডিরেক্টরিতে, chat_membership_update.py নামে একটি ফাইল তৈরি করুন।
  2. chat_membership_update.py এ নিম্নলিখিত কোডটি অন্তর্ভুক্ত করুন:

    from google_auth_oauthlib.flow import InstalledAppFlow
    from googleapiclient.discovery import build
    
    # Define your app's authorization scopes.
    # When modifying these scopes, delete the file token.json, if it exists.
    SCOPES = ["https://www.googleapis.com/auth/chat.memberships"]
    
    def main():
        '''
        Authenticates with Chat API via user credentials,
        then updates a specified space member to change
        it from a regular member to a space manager.
        '''
    
        # Authenticate with Google Workspace
        # and get user authorization.
        flow = InstalledAppFlow.from_client_secrets_file(
                          'client_secrets.json', SCOPES)
        creds = flow.run_local_server()
    
        # Build a service endpoint for Chat API.
        chat = build('chat', 'v1', credentials=creds)
    
        # Use the service endpoint to call Chat API.
        result = chat.spaces().members().patch(
    
            # The membership to update, and the updated role.
            #
            # Replace SPACE with a space name.
            # Obtain the space name from the spaces resource of Chat API,
            # or from a space's URL.
            #
            # Replace MEMBERSHIP with a membership name.
            # Obtain the membership name from the membership of Chat API.
            name='spaces/SPACE/members/MEMBERSHIP',
            updateMask='role',
            body={'role': 'ROLE_MANAGER'}
    
          ).execute()
    
        # Prints details about the updated membership.
        print(result)
    
    if __name__ == '__main__':
        main()
    
  3. কোডে, নিম্নলিখিতগুলি প্রতিস্থাপন করুন:

    • SPACE : একটি স্থানের নাম, যা আপনি Chat API-এর spaces.list পদ্ধতি থেকে বা একটি স্থানের URL থেকে পেতে পারেন।

    • MEMBERSHIP : একটি সদস্যপদ নাম, যা আপনি Chat API-এর spaces.members.list পদ্ধতি থেকে পেতে পারেন।

  4. আপনার কাজের ডিরেক্টরিতে, নমুনা তৈরি করুন এবং চালান:

    python3 chat_membership_update.py
    

Node.js

  1. আপনার কাজের ডিরেক্টরিতে, chat_membership_update.js নামে একটি ফাইল তৈরি করুন।
  2. chat_membership_update.js এ নিম্নলিখিত কোডটি অন্তর্ভুক্ত করুন:

    const chat = require('@googleapis/chat');
    const {authenticate} = require('@google-cloud/local-auth');
    
    /**
    * Updates a membership in a Chat space to change it from
    * a space member to a space manager.
    * @return {!Promise<!Object>}
    */
    async function updateSpace() {
    
      /**
      * Authenticate with Google Workspace
      * and get user authorization.
      */
      const scopes = [
        'https://www.googleapis.com/auth/chat.memberships',
      ];
    
      const authClient =
          await authenticate({scopes, keyfilePath: 'client_secrets.json'});
    
      /**
      * Build a service endpoint for Chat API.
      */
      const chatClient = await chat.chat({version: 'v1', auth: authClient});
    
      /**
      * Use the service endpoint to call Chat API.
      */
      return await chatClient.spaces.patch({
    
        /**
        * The membership to update, and the updated role.
        *
        * Replace SPACE with a space name.
        * Obtain the space name from the spaces resource of Chat API,
        * or from a space's URL.
        *
        * Replace MEMBERSHIP with a membership name.
        * Obtain the membership name from the membership of Chat API.
        */
        name: 'spaces/SPACE/members/MEMBERSHIP',
        updateMask: 'role',
        requestBody: {
          role: 'ROLE_MANAGER'
        }
      });
    }
    
    /**
    * Use the service endpoint to call Chat API.
    */
    updateSpace().then(console.log);
    
  3. কোডে, নিম্নলিখিতগুলি প্রতিস্থাপন করুন:

    • SPACE : একটি স্থানের নাম, যা আপনি Chat API-এর spaces.list পদ্ধতি থেকে বা একটি স্থানের URL থেকে পেতে পারেন।

    • MEMBERSHIP : একটি সদস্যপদ নাম, যা আপনি Chat API-এর spaces.members.list পদ্ধতি থেকে পেতে পারেন।

  4. আপনার কাজের ডিরেক্টরিতে, নমুনা তৈরি করুন এবং চালান:

    python3 chat_membership_update.js
    

অ্যাপস স্ক্রিপ্ট

এই উদাহরণটি উন্নত চ্যাট পরিষেবা ব্যবহার করে চ্যাট API-কে কল করে।

  1. Apps Script প্রকল্পের appsscript.json ফাইলে chat.memberships অনুমোদনের সুযোগ যোগ করুন:

    "oauthScopes": [
      "https://www.googleapis.com/auth/chat.memberships"
    ]
    
  2. অ্যাপস স্ক্রিপ্ট প্রকল্পের কোডে এইরকম একটি ফাংশন যোগ করুন:

    /**
     * Updates a membership from space member to space manager.
     * @param {string} memberName The resource name of the membership.
    */
    function updateMembershipToSpaceManager(memberName) {
      try {
        const body = {'role': 'ROLE_MANAGER'};
        Chat.Spaces.Members.patch(memberName, body);
      } catch (err) {
        // TODO (developer) - Handle exception
        console.log('Failed to create message with error %s', err.message);
      }
    }
    

Google Chat API নির্দিষ্ট মেম্বারশিপকে একজন স্পেস ম্যানেজারে পরিবর্তন করে এবং পরিবর্তনের বিশদ বিবরণ দিয়ে Membership একটি উদাহরণ প্রদান করে।

একজন স্পেস ম্যানেজারকে নিয়মিত সদস্য করুন

নিম্নোক্ত উদাহরণটি একটি স্পেস ম্যানেজারকে একটি নিয়মিত স্পেস সদস্য করে ROLE_MEMBER হিসাবে role নির্দিষ্ট body যা আপডেট করা সদস্যতা বৈশিষ্ট্যগুলি নির্দিষ্ট করে:

পাইথন

  1. আপনার কাজের ডিরেক্টরিতে, chat_membership_update.py নামে একটি ফাইল তৈরি করুন।
  2. chat_membership_update.py এ নিম্নলিখিত কোডটি অন্তর্ভুক্ত করুন:

    from google_auth_oauthlib.flow import InstalledAppFlow
    from googleapiclient.discovery import build
    
    # Define your app's authorization scopes.
    # When modifying these scopes, delete the file token.json, if it exists.
    SCOPES = ["https://www.googleapis.com/auth/chat.memberships"]
    
    def main():
        '''
        Authenticates with Chat API via user credentials,
        then updates a specified space member to change
        it from a regular member to a space manager.
        '''
    
        # Authenticate with Google Workspace
        # and get user authorization.
        flow = InstalledAppFlow.from_client_secrets_file(
                          'client_secrets.json', SCOPES)
        creds = flow.run_local_server()
    
        # Build a service endpoint for Chat API.
        chat = build('chat', 'v1', credentials=creds)
    
        # Use the service endpoint to call Chat API.
        result = chat.spaces().members().patch(
    
            # The membership to update, and the updated role.
            #
            # Replace SPACE with a space name.
            # Obtain the space name from the spaces resource of Chat API,
            # or from a space's URL.
            #
            # Replace MEMBERSHIP with a membership name.
            # Obtain the membership name from the membership of Chat API.
            name='spaces/SPACE/members/MEMBERSHIP',
            updateMask='role',
            body={'role': 'ROLE_MEMBER'}
    
          ).execute()
    
        # Prints details about the updated membership.
        print(result)
    
    if __name__ == '__main__':
        main()
    
  3. কোডে, নিম্নলিখিতগুলি প্রতিস্থাপন করুন:

    • SPACE : একটি স্থানের নাম, যা আপনি Chat API-এর spaces.list পদ্ধতি থেকে বা একটি স্থানের URL থেকে পেতে পারেন।

    • MEMBERSHIP : একটি সদস্যপদ নাম, যা আপনি Chat API-এর spaces.members.list পদ্ধতি থেকে পেতে পারেন।

  4. আপনার কাজের ডিরেক্টরিতে, নমুনা তৈরি করুন এবং চালান:

    python3 chat_membership_update.py
    

Node.js

  1. আপনার কাজের ডিরেক্টরিতে, chat_membership_update.js নামে একটি ফাইল তৈরি করুন।
  2. chat_membership_update.js এ নিম্নলিখিত কোডটি অন্তর্ভুক্ত করুন:

    const chat = require('@googleapis/chat');
    const {authenticate} = require('@google-cloud/local-auth');
    
    /**
    * Updates a membership in a Chat space to change it from
    * a space manager to a space member.
    * @return {!Promise<!Object>}
    */
    async function updateSpace() {
    
      /**
      * Authenticate with Google Workspace
      * and get user authorization.
      */
      const scopes = [
        'https://www.googleapis.com/auth/chat.memberships',
      ];
    
      const authClient =
          await authenticate({scopes, keyfilePath: 'client_secrets.json'});
    
      /**
      * Build a service endpoint for Chat API.
      */
      const chatClient = await chat.chat({version: 'v1', auth: authClient});
    
      /**
      * Use the service endpoint to call Chat API.
      */
      return await chatClient.spaces.patch({
    
        /**
        * The membership to update, and the updated role.
        *
        * Replace SPACE with a space name.
        * Obtain the space name from the spaces resource of Chat API,
        * or from a space's URL.
        *
        * Replace MEMBERSHIP with a membership name.
        * Obtain the membership name from the membership of Chat API.
        */
        name: 'spaces/SPACE/members/MEMBERSHIP',
        updateMask: 'role',
        requestBody: {
          role: 'ROLE_MEMBER'
        }
      });
    }
    
    /**
    * Use the service endpoint to call Chat API.
    */
    updateSpace().then(console.log);
    
  3. কোডে, নিম্নলিখিতগুলি প্রতিস্থাপন করুন:

    • SPACE : একটি স্থানের নাম, যা আপনি Chat API-এর spaces.list পদ্ধতি থেকে বা একটি স্থানের URL থেকে পেতে পারেন।

    • MEMBERSHIP : একটি সদস্যপদ নাম, যা আপনি Chat API-এর spaces.members.list পদ্ধতি থেকে পেতে পারেন।

  4. আপনার কাজের ডিরেক্টরিতে, নমুনা তৈরি করুন এবং চালান:

    python3 chat_membership_update.js
    

অ্যাপস স্ক্রিপ্ট

এই উদাহরণটি উন্নত চ্যাট পরিষেবা ব্যবহার করে চ্যাট API-কে কল করে।

  1. Apps Script প্রকল্পের appsscript.json ফাইলে chat.memberships অনুমোদনের সুযোগ যোগ করুন:

    "oauthScopes": [
      "https://www.googleapis.com/auth/chat.memberships"
    ]
    
  2. অ্যাপস স্ক্রিপ্ট প্রকল্পের কোডে এইরকম একটি ফাংশন যোগ করুন:

    /**
     * Updates a membership from space manager to space member.
     * @param {string} memberName The resource name of the membership.
    */
    function updateMembershipToSpaceMember(memberName) {
      try {
        const body = {'role': 'ROLE_MEMBER'};
        Chat.Spaces.Members.patch(memberName, body);
      } catch (err) {
        // TODO (developer) - Handle exception
        console.log('Failed to create message with error %s', err.message);
      }
    }
    

Google Chat API নির্দিষ্ট মেম্বারশিপকে একজন স্পেস ম্যানেজারে পরিবর্তন করে এবং পরিবর্তনের বিশদ বিবরণ দিয়ে Membership একটি উদাহরণ প্রদান করে।

,

এই নির্দেশিকাটি ব্যাখ্যা করে যে কীভাবে Google Chat API-এর membership সংস্থানে patch পদ্ধতি ব্যবহার করে সদস্যতা সম্পর্কে গুণাবলী পরিবর্তন করতে হয়, যেমন একজন স্পেস মেম্বারকে স্পেস ম্যানেজারে পরিবর্তন করা বা স্পেস ম্যানেজারকে একজন স্পেস সদস্যে পরিবর্তন করা।

Membership রিসোর্স প্রতিনিধিত্ব করে যে একজন মানব ব্যবহারকারী বা Google চ্যাট অ্যাপকে আমন্ত্রণ জানানো হয়েছে কিনা, এর অংশ বা কোনো স্থান থেকে অনুপস্থিত।

পাইথন

  • পাইথন 3.6 বা তার বেশি
  • পাইপ প্যাকেজ ম্যানেজমেন্ট টুল
  • পাইথনের জন্য সর্বশেষ Google ক্লায়েন্ট লাইব্রেরি। এগুলি ইনস্টল বা আপডেট করতে, আপনার কমান্ড-লাইন ইন্টারফেসে নিম্নলিখিত কমান্ডটি চালান:

    pip3 install --upgrade google-api-python-client google-auth-oauthlib
    
  • Google Chat API সক্ষম এবং কনফিগার করা একটি Google ক্লাউড প্রকল্প। ধাপগুলির জন্য, একটি Google Chat অ্যাপ তৈরি করুন দেখুন।
  • চ্যাট অ্যাপের জন্য অনুমোদন কনফিগার করা হয়েছে। একটি সদস্যপদ আপডেট করার জন্য chat.memberships অনুমোদনের সুযোগের সাথে ব্যবহারকারীর প্রমাণীকরণ প্রয়োজন, অথবা, যদি Chat-এ ডেটা আমদানি করা হয় , chat.import অনুমোদনের সুযোগ।

Node.js

  • Node.js এবং npm
  • Node.js-এর জন্য সর্বশেষ Google ক্লায়েন্ট লাইব্রেরি। এগুলি ইনস্টল করতে, আপনার কমান্ড-লাইন ইন্টারফেসে নিম্নলিখিত কমান্ডটি চালান:

    npm install @google-cloud/local-auth @googleapis/chat
    
  • Google Chat API সক্ষম এবং কনফিগার করা একটি Google ক্লাউড প্রকল্প। ধাপগুলির জন্য, একটি Google Chat অ্যাপ তৈরি করুন দেখুন।
  • চ্যাট অ্যাপের জন্য অনুমোদন কনফিগার করা হয়েছে। একটি সদস্যপদ আপডেট করার জন্য chat.memberships অনুমোদনের সুযোগের সাথে ব্যবহারকারীর প্রমাণীকরণ প্রয়োজন, অথবা, যদি Chat-এ ডেটা আমদানি করা হয় , chat.import অনুমোদনের সুযোগ।

অ্যাপস স্ক্রিপ্ট

একটি সদস্যপদ আপডেট করুন

একটি স্থান সদস্যতা আপডেট করতে, আপনার অনুরোধে নিম্নলিখিত পাস করুন:

  • chat.memberships অনুমোদনের সুযোগ নির্দিষ্ট করুন।
  • Membership রিসোর্সে patch মেথড কল করুন এবং আপডেট করার জন্য মেম্বারশিপের name পাস করুন, সেইসাথে updateMask এবং একটি body যা আপডেট করা মেম্বারশিপ অ্যাট্রিবিউট নির্দিষ্ট করে।
  • updateMask আপডেট করার জন্য সদস্যতার দিকগুলি নির্দিষ্ট করে এবং নিম্নলিখিতগুলি অন্তর্ভুক্ত করে:
    • role : একটি চ্যাট স্পেসের মধ্যে ব্যবহারকারীর ভূমিকা, যা স্পেসে তাদের অনুমোদিত ক্রিয়াগুলি নির্ধারণ করে৷ সম্ভাব্য মান হল:
      • ROLE_MEMBER : স্থানের একজন সদস্য। ব্যবহারকারীর মৌলিক অনুমতি রয়েছে, যেমন স্পেসে বার্তা পাঠানো। 1:1 এবং নামহীন গোষ্ঠী কথোপকথনে, প্রত্যেকেরই এই ভূমিকা রয়েছে৷
      • ROLE_MANAGER : একজন স্পেস ম্যানেজার। ব্যবহারকারীর কাছে সমস্ত মৌলিক অনুমতি এবং প্রশাসনিক অনুমতি রয়েছে যা তাদের স্থান পরিচালনা করতে দেয়, যেমন সদস্য যোগ করা বা সরানো। শুধুমাত্র স্পেসগুলিতে সমর্থিত যেখানে spaceType হল SPACE (নামযুক্ত স্থান)।

একজন নিয়মিত স্পেস সদস্যকে স্পেস ম্যানেজার করুন

নিম্নোক্ত উদাহরণটি একটি নিয়মিত স্পেস সদস্যকে একটি স্পেস ম্যানেজার করে ROLE_MANAGER হিসাবে role নির্দিষ্ট body যা আপডেট করা সদস্যতা বৈশিষ্ট্যগুলি নির্দিষ্ট করে:

পাইথন

  1. আপনার কাজের ডিরেক্টরিতে, chat_membership_update.py নামে একটি ফাইল তৈরি করুন।
  2. chat_membership_update.py এ নিম্নলিখিত কোডটি অন্তর্ভুক্ত করুন:

    from google_auth_oauthlib.flow import InstalledAppFlow
    from googleapiclient.discovery import build
    
    # Define your app's authorization scopes.
    # When modifying these scopes, delete the file token.json, if it exists.
    SCOPES = ["https://www.googleapis.com/auth/chat.memberships"]
    
    def main():
        '''
        Authenticates with Chat API via user credentials,
        then updates a specified space member to change
        it from a regular member to a space manager.
        '''
    
        # Authenticate with Google Workspace
        # and get user authorization.
        flow = InstalledAppFlow.from_client_secrets_file(
                          'client_secrets.json', SCOPES)
        creds = flow.run_local_server()
    
        # Build a service endpoint for Chat API.
        chat = build('chat', 'v1', credentials=creds)
    
        # Use the service endpoint to call Chat API.
        result = chat.spaces().members().patch(
    
            # The membership to update, and the updated role.
            #
            # Replace SPACE with a space name.
            # Obtain the space name from the spaces resource of Chat API,
            # or from a space's URL.
            #
            # Replace MEMBERSHIP with a membership name.
            # Obtain the membership name from the membership of Chat API.
            name='spaces/SPACE/members/MEMBERSHIP',
            updateMask='role',
            body={'role': 'ROLE_MANAGER'}
    
          ).execute()
    
        # Prints details about the updated membership.
        print(result)
    
    if __name__ == '__main__':
        main()
    
  3. কোডে, নিম্নলিখিতগুলি প্রতিস্থাপন করুন:

    • SPACE : একটি স্থানের নাম, যা আপনি Chat API-এর spaces.list পদ্ধতি থেকে বা একটি স্থানের URL থেকে পেতে পারেন।

    • MEMBERSHIP : একটি সদস্যপদ নাম, যা আপনি Chat API-এর spaces.members.list পদ্ধতি থেকে পেতে পারেন।

  4. আপনার কাজের ডিরেক্টরিতে, নমুনা তৈরি করুন এবং চালান:

    python3 chat_membership_update.py
    

Node.js

  1. আপনার কাজের ডিরেক্টরিতে, chat_membership_update.js নামে একটি ফাইল তৈরি করুন।
  2. chat_membership_update.js এ নিম্নলিখিত কোডটি অন্তর্ভুক্ত করুন:

    const chat = require('@googleapis/chat');
    const {authenticate} = require('@google-cloud/local-auth');
    
    /**
    * Updates a membership in a Chat space to change it from
    * a space member to a space manager.
    * @return {!Promise<!Object>}
    */
    async function updateSpace() {
    
      /**
      * Authenticate with Google Workspace
      * and get user authorization.
      */
      const scopes = [
        'https://www.googleapis.com/auth/chat.memberships',
      ];
    
      const authClient =
          await authenticate({scopes, keyfilePath: 'client_secrets.json'});
    
      /**
      * Build a service endpoint for Chat API.
      */
      const chatClient = await chat.chat({version: 'v1', auth: authClient});
    
      /**
      * Use the service endpoint to call Chat API.
      */
      return await chatClient.spaces.patch({
    
        /**
        * The membership to update, and the updated role.
        *
        * Replace SPACE with a space name.
        * Obtain the space name from the spaces resource of Chat API,
        * or from a space's URL.
        *
        * Replace MEMBERSHIP with a membership name.
        * Obtain the membership name from the membership of Chat API.
        */
        name: 'spaces/SPACE/members/MEMBERSHIP',
        updateMask: 'role',
        requestBody: {
          role: 'ROLE_MANAGER'
        }
      });
    }
    
    /**
    * Use the service endpoint to call Chat API.
    */
    updateSpace().then(console.log);
    
  3. কোডে, নিম্নলিখিতগুলি প্রতিস্থাপন করুন:

    • SPACE : একটি স্থানের নাম, যা আপনি Chat API-এর spaces.list পদ্ধতি থেকে বা একটি স্থানের URL থেকে পেতে পারেন।

    • MEMBERSHIP : একটি সদস্যপদ নাম, যা আপনি Chat API-এর spaces.members.list পদ্ধতি থেকে পেতে পারেন।

  4. আপনার কাজের ডিরেক্টরিতে, নমুনা তৈরি করুন এবং চালান:

    python3 chat_membership_update.js
    

অ্যাপস স্ক্রিপ্ট

এই উদাহরণটি উন্নত চ্যাট পরিষেবা ব্যবহার করে চ্যাট API-কে কল করে।

  1. Apps Script প্রকল্পের appsscript.json ফাইলে chat.memberships অনুমোদনের সুযোগ যোগ করুন:

    "oauthScopes": [
      "https://www.googleapis.com/auth/chat.memberships"
    ]
    
  2. অ্যাপস স্ক্রিপ্ট প্রকল্পের কোডে এইরকম একটি ফাংশন যোগ করুন:

    /**
     * Updates a membership from space member to space manager.
     * @param {string} memberName The resource name of the membership.
    */
    function updateMembershipToSpaceManager(memberName) {
      try {
        const body = {'role': 'ROLE_MANAGER'};
        Chat.Spaces.Members.patch(memberName, body);
      } catch (err) {
        // TODO (developer) - Handle exception
        console.log('Failed to create message with error %s', err.message);
      }
    }
    

Google Chat API নির্দিষ্ট মেম্বারশিপকে একজন স্পেস ম্যানেজারে পরিবর্তন করে এবং পরিবর্তনের বিশদ বিবরণ দিয়ে Membership একটি উদাহরণ প্রদান করে।

একজন স্পেস ম্যানেজারকে নিয়মিত সদস্য করুন

নিম্নোক্ত উদাহরণটি একটি স্পেস ম্যানেজারকে একটি নিয়মিত স্পেস সদস্য করে ROLE_MEMBER হিসাবে role নির্দিষ্ট body যা আপডেট করা সদস্যতা বৈশিষ্ট্যগুলি নির্দিষ্ট করে:

পাইথন

  1. আপনার কাজের ডিরেক্টরিতে, chat_membership_update.py নামে একটি ফাইল তৈরি করুন।
  2. chat_membership_update.py এ নিম্নলিখিত কোডটি অন্তর্ভুক্ত করুন:

    from google_auth_oauthlib.flow import InstalledAppFlow
    from googleapiclient.discovery import build
    
    # Define your app's authorization scopes.
    # When modifying these scopes, delete the file token.json, if it exists.
    SCOPES = ["https://www.googleapis.com/auth/chat.memberships"]
    
    def main():
        '''
        Authenticates with Chat API via user credentials,
        then updates a specified space member to change
        it from a regular member to a space manager.
        '''
    
        # Authenticate with Google Workspace
        # and get user authorization.
        flow = InstalledAppFlow.from_client_secrets_file(
                          'client_secrets.json', SCOPES)
        creds = flow.run_local_server()
    
        # Build a service endpoint for Chat API.
        chat = build('chat', 'v1', credentials=creds)
    
        # Use the service endpoint to call Chat API.
        result = chat.spaces().members().patch(
    
            # The membership to update, and the updated role.
            #
            # Replace SPACE with a space name.
            # Obtain the space name from the spaces resource of Chat API,
            # or from a space's URL.
            #
            # Replace MEMBERSHIP with a membership name.
            # Obtain the membership name from the membership of Chat API.
            name='spaces/SPACE/members/MEMBERSHIP',
            updateMask='role',
            body={'role': 'ROLE_MEMBER'}
    
          ).execute()
    
        # Prints details about the updated membership.
        print(result)
    
    if __name__ == '__main__':
        main()
    
  3. কোডে, নিম্নলিখিতগুলি প্রতিস্থাপন করুন:

    • SPACE : একটি স্থানের নাম, যা আপনি Chat API-এর spaces.list পদ্ধতি থেকে বা একটি স্থানের URL থেকে পেতে পারেন।

    • MEMBERSHIP : একটি সদস্যপদ নাম, যা আপনি Chat API-এর spaces.members.list পদ্ধতি থেকে পেতে পারেন।

  4. আপনার কাজের ডিরেক্টরিতে, নমুনা তৈরি করুন এবং চালান:

    python3 chat_membership_update.py
    

Node.js

  1. আপনার কাজের ডিরেক্টরিতে, chat_membership_update.js নামে একটি ফাইল তৈরি করুন।
  2. chat_membership_update.js এ নিম্নলিখিত কোডটি অন্তর্ভুক্ত করুন:

    const chat = require('@googleapis/chat');
    const {authenticate} = require('@google-cloud/local-auth');
    
    /**
    * Updates a membership in a Chat space to change it from
    * a space manager to a space member.
    * @return {!Promise<!Object>}
    */
    async function updateSpace() {
    
      /**
      * Authenticate with Google Workspace
      * and get user authorization.
      */
      const scopes = [
        'https://www.googleapis.com/auth/chat.memberships',
      ];
    
      const authClient =
          await authenticate({scopes, keyfilePath: 'client_secrets.json'});
    
      /**
      * Build a service endpoint for Chat API.
      */
      const chatClient = await chat.chat({version: 'v1', auth: authClient});
    
      /**
      * Use the service endpoint to call Chat API.
      */
      return await chatClient.spaces.patch({
    
        /**
        * The membership to update, and the updated role.
        *
        * Replace SPACE with a space name.
        * Obtain the space name from the spaces resource of Chat API,
        * or from a space's URL.
        *
        * Replace MEMBERSHIP with a membership name.
        * Obtain the membership name from the membership of Chat API.
        */
        name: 'spaces/SPACE/members/MEMBERSHIP',
        updateMask: 'role',
        requestBody: {
          role: 'ROLE_MEMBER'
        }
      });
    }
    
    /**
    * Use the service endpoint to call Chat API.
    */
    updateSpace().then(console.log);
    
  3. কোডে, নিম্নলিখিতগুলি প্রতিস্থাপন করুন:

    • SPACE : একটি স্থানের নাম, যা আপনি Chat API-এর spaces.list পদ্ধতি থেকে বা একটি স্থানের URL থেকে পেতে পারেন।

    • MEMBERSHIP : একটি সদস্যপদ নাম, যা আপনি Chat API-এর spaces.members.list পদ্ধতি থেকে পেতে পারেন।

  4. আপনার কাজের ডিরেক্টরিতে, নমুনা তৈরি করুন এবং চালান:

    python3 chat_membership_update.js
    

অ্যাপস স্ক্রিপ্ট

এই উদাহরণটি উন্নত চ্যাট পরিষেবা ব্যবহার করে চ্যাট API-কে কল করে।

  1. Apps Script প্রকল্পের appsscript.json ফাইলে chat.memberships অনুমোদনের সুযোগ যোগ করুন:

    "oauthScopes": [
      "https://www.googleapis.com/auth/chat.memberships"
    ]
    
  2. অ্যাপস স্ক্রিপ্ট প্রকল্পের কোডে এইরকম একটি ফাংশন যোগ করুন:

    /**
     * Updates a membership from space manager to space member.
     * @param {string} memberName The resource name of the membership.
    */
    function updateMembershipToSpaceMember(memberName) {
      try {
        const body = {'role': 'ROLE_MEMBER'};
        Chat.Spaces.Members.patch(memberName, body);
      } catch (err) {
        // TODO (developer) - Handle exception
        console.log('Failed to create message with error %s', err.message);
      }
    }
    

Google Chat API নির্দিষ্ট মেম্বারশিপকে একজন স্পেস ম্যানেজারে পরিবর্তন করে এবং পরিবর্তনের বিশদ বিবরণ দিয়ে Membership একটি উদাহরণ প্রদান করে।