একটি স্থান সম্পর্কে বিবরণ পান

এই নির্দেশিকায় ব্যাখ্যা করা হয়েছে কীভাবে গুগল চ্যাট এপিআই-এর একটি Space রিসোর্সের get মেথড ব্যবহার করে সেই স্পেসের ডিসপ্লে নেম, ডেসক্রিপশন এবং গাইডলাইনের মতো বিবরণ দেখা যায়।

আপনি যদি একজন গুগল ওয়ার্কস্পেস অ্যাডমিনিস্ট্রেটর হন, তাহলে আপনার গুগল ওয়ার্কস্পেস অর্গানাইজেশনের যেকোনো স্পেসের বিবরণ জানতে get মেথডটি কল করতে পারেন।

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

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

অ্যাপ অথেনটিকেশনের মাধ্যমে প্রমাণীকরণ করলে একটি চ্যাট অ্যাপ এমন একটি স্পেসের বিবরণ পেতে পারে, যেটির সে সদস্য। ইউজার অথেনটিকেশনের মাধ্যমে প্রমাণীকরণ করলে আপনি সেই স্পেসগুলোর অ্যাক্সেস পাবেন, যেগুলোতে প্রমাণীকৃত ব্যবহারকারীর অ্যাক্সেস আছে, হয় একজন স্পেস সদস্য হিসেবে অথবা একজন গুগল ওয়ার্কস্পেস অ্যাডমিনিস্ট্রেটর হিসেবে

পূর্বশর্ত

নোড.জেএস

পাইথন

জাভা

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

একটি জায়গা নিন

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

একজন ব্যবহারকারী হিসেবে স্থানের বিবরণ জানুন

ব্যবহারকারী প্রমাণীকরণের মাধ্যমে স্পেসের বিবরণ পাওয়ার উপায় নিচে দেওয়া হলো:

নোড.জেএস

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

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

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

  // Initialize request argument(s)
  const request = {
    // Replace SPACE_NAME here
    name: 'spaces/SPACE_NAME',
  };

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

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

await main();

পাইথন

chat/client-libraries/cloud/get_space_user_cred.py
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 get space with user credential
def get_space_with_user_cred():
    # Create a client
    client = create_client_with_user_credentials(SCOPES)

    # Initialize request argument(s)
    request = google_chat.GetSpaceRequest(
        # Replace SPACE_NAME here
        name = "spaces/SPACE_NAME",
    )

    # Make the request
    response = client.get_space(request)

    # Handle the response
    print(response)

get_space_with_user_cred()

জাভা

chat/client-libraries/cloud/src/main/java/com/google/workspace/api/chat/samples/GetSpaceUserCred.java
import com.google.chat.v1.ChatServiceClient;
import com.google.chat.v1.GetSpaceRequest;
import com.google.chat.v1.Space;

// This sample shows how to get space with user credential.
public class GetSpaceUserCred {

  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))) {
      GetSpaceRequest.Builder request = GetSpaceRequest.newBuilder()
        // Replace SPACE_NAME here
        .setName("spaces/SPACE_NAME");
      Space response = chatServiceClient.getSpace(request.build());

      System.out.println(JsonFormat.printer().print(response));
    }
  }
}

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

chat/advanced-service/Main.gs
/**
 * This sample shows how to get space 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 getSpaceUserCred() {
  // Initialize request argument(s)
  // TODO(developer): Replace SPACE_NAME here
  const name = "spaces/SPACE_NAME";

  // Make the request
  const response = Chat.Spaces.get(name);

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

এই নমুনাটি চালানোর জন্য, SPACE_NAME জায়গায় স্পেসটির name ফিল্ড থেকে পাওয়া ID-টি বসান। আপনি ListSpaces মেথডটি কল করে অথবা স্পেসটির URL থেকে ID-টি পেতে পারেন।

চ্যাট এপিআই Space -এর একটি ইনস্ট্যান্স রিটার্ন করে, যা নির্দিষ্ট স্পেসটির বিবরণ দেয়।

গুগল ওয়ার্কস্পেস প্রশাসক হিসেবে স্পেসের বিবরণ জানুন

আপনি যদি একজন গুগল ওয়ার্কস্পেস অ্যাডমিনিস্ট্রেটর হন, তাহলে আপনার গুগল ওয়ার্কস্পেস অর্গানাইজেশনের যেকোনো স্পেসের বিবরণ জানতে GetSpace মেথডটি কল করতে পারেন।

গুগল ওয়ার্কস্পেস প্রশাসক হিসেবে এই পদ্ধতিটি কল করতে, নিম্নলিখিতগুলি করুন:

  • ব্যবহারকারী প্রমাণীকরণ ব্যবহার করে মেথডটি কল করুন, এবং এমন একটি অনুমোদন পরিধি নির্দিষ্ট করুন যা প্রশাসক বিশেষাধিকার ব্যবহার করে মেথডটি কল করা সমর্থন করে।
  • আপনার অনুরোধে, useAdminAccess কোয়েরি প্যারামিটারটির মান true উল্লেখ করুন।

আরও তথ্য ও উদাহরণের জন্য, Google Workspace প্রশাসক হিসেবে Google Chat স্পেস পরিচালনা দেখুন।

চ্যাট অ্যাপ হিসেবে স্পেসের বিবরণ পান

অ্যাপ অথেন্টিকেশনের মাধ্যমে স্পেসের বিবরণ পাওয়ার উপায় নিচে দেওয়া হলো:

নোড.জেএস

chat/client-libraries/cloud/get-space-app-cred.js
import {createClientWithAppCredentials} from './authentication-utils.js';

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

  // Initialize request argument(s)
  const request = {
    // Replace SPACE_NAME here
    name: 'spaces/SPACE_NAME',
  };

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

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

await main();

পাইথন

chat/client-libraries/cloud/get_space_app_cred.py
from authentication_utils import create_client_with_app_credentials
from google.apps import chat_v1 as google_chat

# This sample shows how to get space with app credential
def get_space_with_app_cred():
    # Create a client
    client = create_client_with_app_credentials()

    # Initialize request argument(s)
    request = google_chat.GetSpaceRequest(
        # Replace SPACE_NAME here
        name = "spaces/SPACE_NAME",
    )

    # Make the request
    response = client.get_space(request)

    # Handle the response
    print(response)

get_space_with_app_cred()

জাভা

chat/client-libraries/cloud/src/main/java/com/google/workspace/api/chat/samples/GetSpaceAppCred.java
import com.google.chat.v1.ChatServiceClient;
import com.google.chat.v1.GetSpaceRequest;
import com.google.chat.v1.Space;

// This sample shows how to get space with app credential.
public class GetSpaceAppCred {

  public static void main(String[] args) throws Exception {
    try (ChatServiceClient chatServiceClient =
        AuthenticationUtils.createClientWithAppCredentials()) {
      GetSpaceRequest.Builder request = GetSpaceRequest.newBuilder()
        // Replace SPACE_NAME here
        .setName("spaces/SPACE_NAME");
      Space response = chatServiceClient.getSpace(request.build());

      System.out.println(JsonFormat.printer().print(response));
    }
  }
}

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

chat/advanced-service/Main.gs
/**
 * This sample shows how to get space with app credential
 *
 * It relies on the OAuth2 scope 'https://www.googleapis.com/auth/chat.bot'
 * used by service accounts.
 */
function getSpaceAppCred() {
  // Initialize request argument(s)
  // TODO(developer): Replace SPACE_NAME here
  const name = "spaces/SPACE_NAME";
  const parameters = {};

  // Make the request
  const response = Chat.Spaces.get(
    name,
    parameters,
    getHeaderWithAppCredentials(),
  );

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

এই নমুনাটি চালানোর জন্য, SPACE_NAME জায়গায় স্পেসটির name ফিল্ড থেকে পাওয়া ID-টি বসান। আপনি ListSpaces মেথডটি কল করে অথবা স্পেসটির URL থেকে ID-টি পেতে পারেন।

চ্যাট এপিআই Space -এর একটি ইনস্ট্যান্স রিটার্ন করে, যা নির্দিষ্ট স্পেসটির বিবরণ দেয়।

সীমাবদ্ধতা এবং বিবেচ্য বিষয়

  • accessSettings ( accessPermissionSettings সহ), predefinedPermissionSettings , এবং permissionSettings ফিল্ডগুলো শুধুমাত্র তখনই পূরণ হয় যখন আপনি chat.app.spaces স্কোপ ব্যবহার করে প্রমাণীকরণ করেন, এবং অনুমতি সেটিংসগুলো চ্যাট অ্যাপ দ্বারা তৈরি স্পেসগুলোর মধ্যেই সীমাবদ্ধ থাকে।