স্পেস তালিকা

এই নির্দেশিকাটি ব্যাখ্যা করে যে কীভাবে Google Chat API-এর Space রিসোর্সে list() পদ্ধতি ব্যবহার করে স্পেস তালিকাভুক্ত করতে হয়। Listing spaces একটি পৃষ্ঠাঙ্কিত, ফিল্টারযোগ্য স্পেসের তালিকা প্রদান করে।

Space রিসোর্স এমন একটি জায়গা যেখানে মানুষ এবং চ্যাট অ্যাপ বার্তা পাঠাতে, ফাইল শেয়ার করতে এবং সহযোগিতা করতে পারে। বিভিন্ন ধরণের স্পেস আছে:

  • ডাইরেক্ট মেসেজ (DM) হলো দুজন ব্যবহারকারী অথবা একজন ব্যবহারকারী এবং একটি চ্যাট অ্যাপের মধ্যে কথোপকথন।
  • গ্রুপ চ্যাট হলো তিন বা ততোধিক ব্যবহারকারী এবং চ্যাট অ্যাপের মধ্যে কথোপকথন।
  • নামযুক্ত স্থানগুলি হল স্থায়ী স্থান যেখানে লোকেরা বার্তা পাঠায়, ফাইল শেয়ার করে এবং সহযোগিতা করে।

অ্যাপ প্রমাণীকরণ সহ তালিকাভুক্ত স্থানগুলি চ্যাট অ্যাপের অ্যাক্সেসযোগ্য স্থানগুলির তালিকা করে। ব্যবহারকারী প্রমাণীকরণ সহ তালিকাভুক্ত স্থানগুলি প্রমাণীকরণযুক্ত ব্যবহারকারীর অ্যাক্সেসযোগ্য স্থানগুলির তালিকা করে।

পূর্বশর্ত

নোড.জেএস

  • Google Chat অ্যাক্সেস সহ একটি ব্যবসা বা এন্টারপ্রাইজ Google Workspace অ্যাকাউন্ট।

পাইথন

  • Google Chat অ্যাক্সেস সহ একটি ব্যবসা বা এন্টারপ্রাইজ Google Workspace অ্যাকাউন্ট।

জাভা

  • Google Chat অ্যাক্সেস সহ একটি ব্যবসা বা এন্টারপ্রাইজ Google Workspace অ্যাকাউন্ট।

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

  • Google Chat অ্যাক্সেস সহ একটি ব্যবসা বা এন্টারপ্রাইজ Google Workspace অ্যাকাউন্ট।

ব্যবহারকারী প্রমাণীকরণ সহ তালিকাভুক্ত স্থানগুলি

গুগল চ্যাটে স্পেস তালিকাভুক্ত করতে, আপনার অনুরোধে নিম্নলিখিতগুলি পাস করুন:

নিম্নলিখিত উদাহরণে প্রমাণীকৃত ব্যবহারকারীর কাছে দৃশ্যমান নামযুক্ত স্পেসগুলি (কিন্তু গ্রুপ চ্যাট এবং সরাসরি বার্তা নয়, যা ফিল্টার করা হয়) তালিকাভুক্ত করা হয়েছে:

নোড.জেএস

চ্যাট/ক্লায়েন্ট-লাইব্রেরি/ক্লাউড/লিস্ট-স্পেস-ইউজার-ক্রেড.জেএস
import {createClientWithUserCredentials} from './authentication-utils.js';

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

// This sample shows how to list spaces with user credential
async function main() {
  // Create a client
  const chatClient = await createClientWithUserCredentials(
    USER_AUTH_OAUTH_SCOPES,
  );

  // Initialize request argument(s)
  const request = {
    // Filter spaces by space type (SPACE or GROUP_CHAT or DIRECT_MESSAGE)
    filter: 'space_type = "SPACE"',
  };

  // Make the request
  const pageResult = chatClient.listSpacesAsync(request);

  // Handle the response. Iterating over pageResult will yield results
  // and resolve additional pages automatically.
  for await (const response of pageResult) {
    console.log(response);
  }
}

await main();

পাইথন

চ্যাট/ক্লায়েন্ট-লাইব্রেরি/ক্লাউড/লিস্ট_স্পেস_ইউজার_ক্রেড.পি
from authentication_utils import create_client_with_user_credentials
from google.apps import chat_v1 as google_chat

SCOPES = ["https://www.googleapis.com/auth/chat.spaces.readonly"]

# This sample shows how to list spaces with user credential
def list_spaces_with_user_cred():
    # Create a client
    client = create_client_with_user_credentials(SCOPES)

    # Initialize request argument(s)
    request = google_chat.ListSpacesRequest(
        # Filter spaces by space type (SPACE or GROUP_CHAT or DIRECT_MESSAGE)
        filter = 'space_type = "SPACE"',
        # Number of results that will be returned at once
        page_size = 100
    )

    # Make the request
    page_result = client.list_spaces(request)

    # Handle the response. Iterating over page_result will yield results and
    # resolve additional pages automatically.
    for response in page_result:
        print(response)

list_spaces_with_user_cred()

জাভা

চ্যাট/ক্লায়েন্ট-লাইব্রেরি/ক্লাউড/এসআরসি/মেইন/জাভা/কম/গুগল/ওয়ার্কস্পেস/এপিআই/চ্যাট/স্যাম্পল/লিস্টস্পেসেসইউজারক্রেড.জাভা
import com.google.chat.v1.ChatServiceClient;
import com.google.chat.v1.ListSpacesRequest;
import com.google.chat.v1.ListSpacesResponse;
import com.google.chat.v1.Space;

// This sample shows how to list spaces with user credential.
public class ListSpacesUserCred{

  private static final String SCOPE =
    "https://www.googleapis.com/auth/chat.spaces.readonly";

  public static void main(String[] args) throws Exception {
    try (ChatServiceClient chatServiceClient =
        AuthenticationUtils.createClientWithUserCredentials(
          ImmutableList.of(SCOPE))) {
      ListSpacesRequest.Builder request = ListSpacesRequest.newBuilder()
        // Filter spaces by space type (SPACE or GROUP_CHAT or
        // DIRECT_MESSAGE).
        .setFilter("spaceType = \"SPACE\"")
        // Number of results that will be returned at once.
        .setPageSize(10);

      // Iterate over results and resolve additional pages automatically.
      for (Space response :
          chatServiceClient.listSpaces(request.build()).iterateAll()) {
        System.out.println(JsonFormat.printer().print(response));
      }
    }
  }
}

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

চ্যাট/অ্যাডভান্সড-সার্ভিস/মেইন.জি.এস
/**
 * This sample shows how to list spaces with user credential
 *
 * It relies on the OAuth2 scope 'https://www.googleapis.com/auth/chat.spaces.readonly'
 * referenced in the manifest file (appsscript.json).
 */
function listSpacesUserCred() {
  // Initialize request argument(s)
  // Filter spaces by space type (SPACE or GROUP_CHAT or DIRECT_MESSAGE)
  const filter = 'space_type = "SPACE"';

  // Iterate through the response pages using page tokens
  let responsePage;
  let pageToken = null;
  do {
    // Request response pages
    responsePage = Chat.Spaces.list({
      filter: filter,
      pageSize: 10,
      pageToken: pageToken,
    });
    // Handle response pages
    if (responsePage.spaces) {
      for (const space of responsePage.spaces) {
        console.log(space);
      }
    }
    // Update the page token to the next one
    pageToken = responsePage.nextPageToken;
  } while (pageToken);
}

চ্যাট API স্পেসের একটি পৃষ্ঠাযুক্ত তালিকা প্রদান করে।

অ্যাপ প্রমাণীকরণ সহ স্পেস তালিকাভুক্ত করুন

গুগল চ্যাটে স্পেস তালিকাভুক্ত করতে, আপনার অনুরোধে নিম্নলিখিতগুলি পাস করুন:

নিম্নলিখিত উদাহরণে চ্যাট অ্যাপে দৃশ্যমান নামযুক্ত স্পেসগুলি (কিন্তু গ্রুপ চ্যাট এবং সরাসরি বার্তা নয়) তালিকাভুক্ত করা হয়েছে:

নোড.জেএস

চ্যাট/ক্লায়েন্ট-লাইব্রেরি/ক্লাউড/লিস্ট-স্পেস-অ্যাপ-ক্রেড.জেএস
import {createClientWithAppCredentials} from './authentication-utils.js';

// This sample shows how to list spaces with app credential
async function main() {
  // Create a client
  const chatClient = createClientWithAppCredentials();

  // Initialize request argument(s)
  const request = {
    // Filter spaces by space type (SPACE or GROUP_CHAT or DIRECT_MESSAGE)
    filter: 'space_type = "SPACE"',
  };

  // Make the request
  const pageResult = chatClient.listSpacesAsync(request);

  // Handle the response. Iterating over pageResult will yield results
  // and resolve additional pages automatically.
  for await (const response of pageResult) {
    console.log(response);
  }
}

await main();

পাইথন

চ্যাট/ক্লায়েন্ট-লাইব্রেরি/ক্লাউড/লিস্ট_স্পেস_অ্যাপ_ক্রেড.পি
from authentication_utils import create_client_with_app_credentials
from google.apps import chat_v1 as google_chat

# This sample shows how to list spaces with app credential
def list_spaces_app_cred():
    # Create a client
    client = create_client_with_app_credentials()

    # Initialize request argument(s)
    request = google_chat.ListSpacesRequest(
        # Filter spaces by space type (SPACE or GROUP_CHAT or DIRECT_MESSAGE)
        filter = 'space_type = "SPACE"',
        # Number of results that will be returned at once
        page_size = 100
    )

    # Make the request
    page_result = client.list_spaces(request)

    # Handle the response. Iterating over page_result will yield results and
    # resolve additional pages automatically.
    for response in page_result:
        print(response)

list_spaces_app_cred()

জাভা

চ্যাট/ক্লায়েন্ট-লাইব্রেরি/ক্লাউড/এসআরসি/মেইন/জাভা/কম/গুগল/ওয়ার্কস্পেস/এপিআই/চ্যাট/স্যাম্পল/লিস্টস্পেসঅ্যাপক্রেড.জাভা
import com.google.chat.v1.ChatServiceClient;
import com.google.chat.v1.ListSpacesRequest;
import com.google.chat.v1.ListSpacesResponse;
import com.google.chat.v1.Space;

// This sample shows how to list spaces with app credential.
public class ListSpacesAppCred {

  public static void main(String[] args) throws Exception {
    try (ChatServiceClient chatServiceClient =
        AuthenticationUtils.createClientWithAppCredentials()) {
      ListSpacesRequest.Builder request = ListSpacesRequest.newBuilder()
        // Filter spaces by space type (SPACE or GROUP_CHAT or
        // DIRECT_MESSAGE).
        .setFilter("spaceType = \"SPACE\"")
        // Number of results that will be returned at once.
        .setPageSize(10);

      // Iterate over results and resolve additional pages automatically.
      for (Space response :
          chatServiceClient.listSpaces(request.build()).iterateAll()) {
        System.out.println(JsonFormat.printer().print(response));
      }
    }
  }
}

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

চ্যাট/অ্যাডভান্সড-সার্ভিস/মেইন.জি.এস
/**
 * This sample shows how to list spaces with app credential
 *
 * It relies on the OAuth2 scope 'https://www.googleapis.com/auth/chat.bot'
 * used by service accounts.
 */
function listSpacesAppCred() {
  // Initialize request argument(s)
  // Filter spaces by space type (SPACE or GROUP_CHAT or DIRECT_MESSAGE)
  const filter = 'space_type = "SPACE"';

  // Iterate through the response pages using page tokens
  let responsePage;
  let pageToken = null;
  do {
    // Request response pages
    responsePage = Chat.Spaces.list(
      {
        filter: filter,
        pageSize: 10,
        pageToken: pageToken,
      },
      getHeaderWithAppCredentials(),
    );
    // Handle response pages
    if (responsePage.spaces) {
      for (const space of responsePage.spaces) {
        console.log(space);
      }
    }
    // Update the page token to the next one
    pageToken = responsePage.nextPageToken;
  } while (pageToken);
}

চ্যাট API স্পেসের একটি পৃষ্ঠাযুক্ত তালিকা প্রদান করে।

পৃষ্ঠাঙ্কন কাস্টমাইজ করুন অথবা তালিকা ফিল্টার করুন

গুগল চ্যাটে স্পেস তালিকাভুক্ত করতে, তালিকাভুক্ত স্পেসগুলির পৃষ্ঠাঙ্কন কাস্টমাইজ করতে বা ফিল্টার করতে নিম্নলিখিত ঐচ্ছিক কোয়েরি প্যারামিটারগুলি পাস করুন:

  • pageSize : সর্বাধিক কতটি স্পেস ফেরত পাঠানো যাবে। পরিষেবাটি এই মানের চেয়ে কম স্পেস ফেরত দিতে পারে। যদি নির্দিষ্ট না করা থাকে, তাহলে সর্বাধিক ১০০টি স্পেস ফেরত দেওয়া হবে। সর্বোচ্চ মান হল ১,০০০; ১,০০০ এর বেশি মান স্বয়ংক্রিয়ভাবে ১,০০০ এ পরিবর্তিত হবে।
  • pageToken : একটি পৃষ্ঠা টোকেন, যা পূর্ববর্তী তালিকা স্পেস কল থেকে প্রাপ্ত। পরবর্তী পৃষ্ঠাটি পুনরুদ্ধার করার জন্য এই টোকেনটি প্রদান করুন। পৃষ্ঠাকরণের সময়, ফিল্টার মানটি পৃষ্ঠা টোকেন প্রদানকারী কলের সাথে মিলিত হওয়া উচিত। একটি ভিন্ন মান পাস করলে অপ্রত্যাশিত ফলাফল হতে পারে।
  • filter : একটি কোয়েরি ফিল্টার। সমর্থিত কোয়েরির বিশদ বিবরণের জন্য, ListSpacesRequest রেফারেন্স দেখুন।