किसी स्पेस के बारे में जानकारी पाना

इस गाइड में, Google Chat API के Space संसाधन पर get तरीके का इस्तेमाल करके, किसी स्पेस के बारे में जानकारी देखने का तरीका बताया गया है, जैसे, उसका डिसप्ले नेम, जानकारी, और दिशा-निर्देश.

अगर आप Google Workspace एडमिन हैं, तो get तरीके को कॉल करके, अपने Google Workspace संगठन में मौजूद किसी भी स्पेस के बारे में जानकारी हासिल की जा सकती है.

`Space` संसाधन, एक ऐसी जगह होती है जहां लोग और Chat ऐप्लिकेशन, मैसेज भेज सकते हैं, फ़ाइलें शेयर कर सकते हैं, और मिलकर काम कर सकते हैं.Space स्पेस कई तरह के होते हैं:

  • डायरेक्ट मैसेज (डीएम), दो उपयोगकर्ताओं या किसी उपयोगकर्ता और Chat ऐप्लिकेशन के बीच की बातचीत होती है.
  • ग्रुप चैट, तीन या इससे ज़्यादा उपयोगकर्ताओं और Chat ऐप्लिकेशन के बीच की बातचीत होती है.
  • नाम वाले स्पेस, ऐसी जगहें होती हैं जहां लोग मैसेज भेजते हैं, फ़ाइलें शेयर करते हैं, और मिलकर काम करते हैं.

ऐप्लिकेशन की पुष्टि करने की सुविधा से पुष्टि करने पर, Chat ऐप्लिकेशन को उस स्पेस के बारे में जानकारी मिलती है जिसका वह सदस्य है. उपयोगकर्ता की पुष्टि करने की सुविधा से पुष्टि करने पर, आपको वे स्पेस मिलते हैं जिन्हें पुष्टि किए गए उपयोगकर्ता ने ऐक्सेस किया है. ऐसा स्पेस के सदस्य या Google Workspace एडमिन के तौर पर किया जा सकता है.

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

Node.js

Python

Java

Apps Script

कोई स्पेस पाना

Google Chat में कोई स्पेस पाने के लिए, अपने अनुरोध में यह जानकारी शामिल करें:

उपयोगकर्ता के तौर पर स्पेस की जानकारी पाना

उपयोगकर्ता की पुष्टि करने की सुविधा के साथ, स्पेस की जानकारी पाने का तरीका यहां बताया गया है: उपयोगकर्ता की पुष्टि:

Node.js

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();

Python

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()

Java

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));
    }
  }
}

Apps Script

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 फ़ील्ड से आईडी डालें. `ListSpaces` तरीके को कॉल करके या स्पेस के यूआरएल से आईडी हासिल किया जा सकता है.ListSpaces

Chat API, Space का एक ऐसा इंस्टेंस दिखाता है जिसमें तय किए गए स्पेस की जानकारी होती है.

Google Workspace एडमिन के तौर पर स्पेस की जानकारी पाना

अगर आप Google Workspace एडमिन हैं, तो GetSpace तरीके को कॉल करके, अपने Google Workspace संगठन में मौजूद किसी भी स्पेस के बारे में जानकारी हासिल की जा सकती है.

Google Workspace एडमिन के तौर पर इस तरीके को कॉल करने के लिए, यह तरीका अपनाएं:

ज़्यादा जानकारी और उदाहरणों के लिए, Google Workspace एडमिन के तौर पर Google Chat स्पेस मैनेज करना देखें.

Chat ऐप्लिकेशन के तौर पर स्पेस की जानकारी पाना

ऐप्लिकेशन की पुष्टि करने की सुविधा के साथ, स्पेस की जानकारी पाने का तरीका यहां बताया गया है:

Node.js

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();

Python

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()

Java

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));
    }
  }
}

Apps Script

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 फ़ील्ड से आईडी डालें. `ListSpaces` तरीके को कॉल करके या स्पेस के यूआरएल से आईडी हासिल किया जा सकता है.ListSpaces

Chat API, Space का एक ऐसा इंस्टेंस दिखाता है जिसमें तय किए गए स्पेस की जानकारी होती है.

सीमाएं और ज़रूरी बातें

  • The accessSettings (जिसमें accessPermissionSettings शामिल है), predefinedPermissionSettings, और permissionSettings फ़ील्ड में जानकारी सिर्फ़ तब दिखती है, जब chat.app.spaces लिंक से पुष्टि की जाती है. साथ ही, अनुमति की सेटिंग सिर्फ़ उन स्पेस के लिए सीमित होती हैं जिन्हें Chat ऐप्लिकेशन ने बनाया है.