Làm việc với không gian hội họp

Hình minh hoạ API REST của Google Meet

Hướng dẫn này giải thích cách tạo, lấy và cập nhật không gian họp, cũng như cách kết thúc cuộc họp đang hoạt động trên tài nguyên spaces của API Google Meet REST.

Không gian họp đại diện cho một địa điểm ảo hoặc một đối tượng ổn định (chẳng hạn như phòng họp) nơi diễn ra các hội nghị. Tại một thời điểm, mỗi không gian chỉ có thể tổ chức một hội nghị đang hoạt động. Không gian họp cũng giúp người dùng gặp gỡ và tìm thấy tài nguyên dùng chung.

Để tìm hiểu cách định cấu hình không gian họp theo phương thức lập trình, hãy xem phần Định cấu hình không gian họp và thành viên.

Bảng sau đây trình bày chi tiết các vai trò trong cuộc họp cần thiết để sử dụng các phương thức của không gian họp:

Phương thức Chủ sở hữu Người tham gia Khác
endActiveConference() x
get() x x x
     có chế độ cài đặt x
     có hội nghị đang hoạt động x x
patch() x

Việc xác thực và uỷ quyền bằng thông tin đăng nhập của người dùng cho phép các ứng dụng Google Meet truy cập vào dữ liệu người dùng và thực hiện các thao tác thay mặt cho người dùng đã xác thực. Việc xác thực bằng tính năng uỷ quyền trên toàn miền cho phép bạn uỷ quyền cho tài khoản dịch vụ của ứng dụng truy cập vào dữ liệu của người dùng mà không yêu cầu mỗi người dùng phải đồng ý.

Cách Meet xác định không gian của cuộc họp

API REST của Google Meet tạo một tài nguyên spaces cho mỗi không gian họp. Trường name là tên tài nguyên cho tài nguyên.

Sau đây là hai cách quan trọng để xác định không gian họp bằng trường name:

  • space là giá trị nhận dạng tài nguyên cho không gian, được định dạng là spaces/{space}. Đây là mã nhận dạng duy nhất do máy chủ tạo và phân biệt chữ hoa chữ thường. Ví dụ: spaces/jQCFfuBOdN5z.

  • meetingCode là bí danh của không gian, được định dạng là spaces/{meetingCode}. Đây là một chuỗi ký tự duy nhất, có thể nhập và không phân biệt chữ hoa chữ thường. Ví dụ: abc-mnop-xyz. Độ dài tối đa là 128 ký tự. Thuộc tính này là một phần của meetingUri: https://meet.google.com/abc-mnop-xyz.

Để quản lý không gian họp, hãy sử dụng các giá trị sau cho trường {name}:

  • Để biết thông tin chi tiết về không gian họp, bạn có thể sử dụng spaces/{space} hoặc tên đại diện spaces/{meetingCode}. Để biết thêm thông tin, hãy xem bài viết Tạo không gian họp.

  • Để cập nhật thông tin chi tiết về không gian họp, bạn chỉ có thể sử dụng spaces/{space}. Để biết thêm thông tin, hãy xem bài viết Cập nhật không gian họp.

  • Để kết thúc một cuộc họp đang hoạt động trong phòng họp, bạn chỉ có thể sử dụng spaces/{space}. Để biết thêm thông tin, hãy xem phần Kết thúc cuộc họp đang diễn ra.

Tạo không gian họp

Để tạo không gian họp, hãy sử dụng phương thức create() trên tài nguyên spaces.

Phương thức này trả về một thực thể của tài nguyên spaces, bao gồm đối tượng SpaceConfig là cấu hình cho không gian họp. Tệp này cũng chứa đối tượng ActiveConference là đường liên kết đến tài nguyên conferenceRecords hiện tại trong không gian họp.

Mã mẫu sau đây cho biết cách tạo không gian họp:

Java

java-meet/samples/snippets/generated/com/google/apps/meet/v2/spacesservice/createspace/AsyncCreateSpace.java
import com.google.api.core.ApiFuture;
import com.google.apps.meet.v2.CreateSpaceRequest;
import com.google.apps.meet.v2.Space;
import com.google.apps.meet.v2.SpacesServiceClient;

public class AsyncCreateSpace {

  public static void main(String[] args) throws Exception {
    asyncCreateSpace();
  }

  public static void asyncCreateSpace() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (SpacesServiceClient spacesServiceClient = SpacesServiceClient.create()) {
      CreateSpaceRequest request =
          CreateSpaceRequest.newBuilder().setSpace(Space.newBuilder().build()).build();
      ApiFuture<Space> future = spacesServiceClient.createSpaceCallable().futureCall(request);
      // Do something.
      Space response = future.get();
    }
  }
}

Node.js

packages/google-apps-meet/samples/generated/v2/spaces_service.create_space.js
/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Space to be created. As of May 2023, the input space can be empty. Later on
 *  the input space can be non-empty when space configuration is introduced.
 */
// const space = {}

// Imports the Meet library
const {SpacesServiceClient} = require('@google-apps/meet').v2;

// Instantiates a client
const meetClient = new SpacesServiceClient();

async function callCreateSpace() {
  // Construct request
  const request = {
  };

  // Run request
  const response = await meetClient.createSpace(request);
  console.log(response);
}

callCreateSpace();

Python

packages/google-apps-meet/samples/generated_samples/meet_v2_generated_spaces_service_create_space_async.py
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.apps import meet_v2


async def sample_create_space():
    # Create a client
    client = meet_v2.SpacesServiceAsyncClient()

    # Initialize request argument(s)
    request = meet_v2.CreateSpaceRequest(
    )

    # Make the request
    response = await client.create_space(request=request)

    # Handle the response
    print(response)

Xem thông tin chi tiết về không gian họp

Để biết thông tin chi tiết về không gian họp đang hoạt động và các chế độ cài đặt của không gian họp đó, hãy sử dụng phương thức get() trên tài nguyên spaces với name được chỉ định. Để biết thêm thông tin, hãy xem bài viết Cách Meet xác định không gian họp.

Phương thức này trả về một không gian họp dưới dạng một thực thể của tài nguyên spaces.

Mã mẫu sau đây cho biết cách truy xuất không gian họp:

Java

java-meet/samples/snippets/generated/com/google/apps/meet/v2/spacesservice/getspace/AsyncGetSpace.java
import com.google.api.core.ApiFuture;
import com.google.apps.meet.v2.GetSpaceRequest;
import com.google.apps.meet.v2.Space;
import com.google.apps.meet.v2.SpaceName;
import com.google.apps.meet.v2.SpacesServiceClient;

public class AsyncGetSpace {

  public static void main(String[] args) throws Exception {
    asyncGetSpace();
  }

  public static void asyncGetSpace() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (SpacesServiceClient spacesServiceClient = SpacesServiceClient.create()) {
      GetSpaceRequest request =
          GetSpaceRequest.newBuilder().setName(SpaceName.of("[SPACE]").toString()).build();
      ApiFuture<Space> future = spacesServiceClient.getSpaceCallable().futureCall(request);
      // Do something.
      Space response = future.get();
    }
  }
}

Node.js

packages/google-apps-meet/samples/generated/v2/spaces_service.get_space.js
/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. Resource name of the space.
 *  Format: `spaces/{space}` or `spaces/{meetingCode}`.
 *  `{space}` is the resource identifier for the space. It's a unique,
 *  server-generated ID and is case sensitive. For example, `jQCFfuBOdN5z`.
 *  `{meetingCode}` is an alias for the space. It's a typeable, unique
 *  character string and is non-case sensitive. For example, `abc-mnop-xyz`.
 *  The maximum length is 128 characters.
 *  A `meetingCode` shouldn't be stored long term as it can become
 *  dissociated from a meeting space and can be reused for different meeting
 *  spaces in the future. Generally, a `meetingCode` expires 365 days after
 *  last use. For more information, see Learn about meeting codes in Google
 *  Meet (https://support.google.com/meet/answer/10710509).
 *  For more information, see How Meet identifies a meeting
 *  space (https://developers.google.com/meet/api/guides/meeting-spaces#identify-meeting-space).
 */
// const name = 'abc123'

// Imports the Meet library
const {SpacesServiceClient} = require('@google-apps/meet').v2;

// Instantiates a client
const meetClient = new SpacesServiceClient();

async function callGetSpace() {
  // Construct request
  const request = {
    name,
  };

  // Run request
  const response = await meetClient.getSpace(request);
  console.log(response);
}

callGetSpace();

Python

packages/google-apps-meet/samples/generated_samples/meet_v2_generated_spaces_service_get_space_async.py
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.apps import meet_v2


async def sample_get_space():
    # Create a client
    client = meet_v2.SpacesServiceAsyncClient()

    # Initialize request argument(s)
    request = meet_v2.GetSpaceRequest(
        name="name_value",
    )

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

    # Handle the response
    print(response)

Thay thế giá trị tên không gian bằng mã nhận dạng duy nhất do máy chủ tạo cho không gian họp.

Cập nhật không gian họp

Để cập nhật thông tin chi tiết về không gian họp, hãy sử dụng phương thức patch() trên tài nguyên spaces với name được chỉ định. Để biết thêm thông tin, hãy xem bài viết Cách Meet xác định không gian họp.

Phương thức patch() cũng sử dụng tham số truy vấn updateMask không bắt buộc. Trường thuộc loại FieldMask. Đây là danh sách các trường bạn muốn cập nhật trong không gian, được phân tách bằng dấu phẩy.

Phương thức này trả về một không gian họp dưới dạng một thực thể của tài nguyên spaces.

Mã mẫu sau đây cho biết cách cập nhật không gian họp:

Java

java-meet/samples/snippets/generated/com/google/apps/meet/v2/spacesservice/updatespace/AsyncUpdateSpace.java
import com.google.api.core.ApiFuture;
import com.google.apps.meet.v2.Space;
import com.google.apps.meet.v2.SpacesServiceClient;
import com.google.apps.meet.v2.UpdateSpaceRequest;
import com.google.protobuf.FieldMask;

public class AsyncUpdateSpace {

  public static void main(String[] args) throws Exception {
    asyncUpdateSpace();
  }

  public static void asyncUpdateSpace() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (SpacesServiceClient spacesServiceClient = SpacesServiceClient.create()) {
      UpdateSpaceRequest request =
          UpdateSpaceRequest.newBuilder()
              .setSpace(Space.newBuilder().build())
              .setUpdateMask(FieldMask.newBuilder().build())
              .build();
      ApiFuture<Space> future = spacesServiceClient.updateSpaceCallable().futureCall(request);
      // Do something.
      Space response = future.get();
    }
  }
}

Node.js

packages/google-apps-meet/samples/generated/v2/spaces_service.update_space.js
/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. Space to be updated.
 */
// const space = {}
/**
 *  Optional. Field mask used to specify the fields to be updated in the space.
 *  If update_mask isn't provided(not set, set with empty paths, or only has ""
 *  as paths), it defaults to update all fields provided with values in the
 *  request.
 *  Using "*" as update_mask will update all fields, including deleting fields
 *  not set in the request.
 */
// const updateMask = {}

// Imports the Meet library
const {SpacesServiceClient} = require('@google-apps/meet').v2;

// Instantiates a client
const meetClient = new SpacesServiceClient();

async function callUpdateSpace() {
  // Construct request
  const request = {
    space,
  };

  // Run request
  const response = await meetClient.updateSpace(request);
  console.log(response);
}

callUpdateSpace();

Python

packages/google-apps-meet/samples/generated_samples/meet_v2_generated_spaces_service_update_space_async.py
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.apps import meet_v2


async def sample_update_space():
    # Create a client
    client = meet_v2.SpacesServiceAsyncClient()

    # Initialize request argument(s)
    request = meet_v2.UpdateSpaceRequest(
    )

    # Make the request
    response = await client.update_space(request=request)

    # Handle the response
    print(response)

Thay thế giá trị tên không gian bằng mã nhận dạng duy nhất do máy chủ tạo cho không gian họp.

Kết thúc hội nghị đang hoạt động

Để kết thúc một cuộc họp đang hoạt động trong không gian họp (nếu có), hãy sử dụng phương thức endActiveConference() trên tài nguyên spaces. Cả nội dung yêu cầu và nội dung phản hồi đều trống. Để biết thêm thông tin, hãy xem bài viết Cách Meet xác định không gian họp.

Mã mẫu sau đây cho biết cách kết thúc một cuộc họp đang hoạt động:

Java

java-meet/samples/snippets/generated/com/google/apps/meet/v2/spacesservice/endactiveconference/AsyncEndActiveConference.java
import com.google.api.core.ApiFuture;
import com.google.apps.meet.v2.EndActiveConferenceRequest;
import com.google.apps.meet.v2.SpaceName;
import com.google.apps.meet.v2.SpacesServiceClient;
import com.google.protobuf.Empty;

public class AsyncEndActiveConference {

  public static void main(String[] args) throws Exception {
    asyncEndActiveConference();
  }

  public static void asyncEndActiveConference() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (SpacesServiceClient spacesServiceClient = SpacesServiceClient.create()) {
      EndActiveConferenceRequest request =
          EndActiveConferenceRequest.newBuilder()
              .setName(SpaceName.of("[SPACE]").toString())
              .build();
      ApiFuture<Empty> future =
          spacesServiceClient.endActiveConferenceCallable().futureCall(request);
      // Do something.
      future.get();
    }
  }
}

Node.js

packages/google-apps-meet/samples/generated/v2/spaces_service.end_active_conference.js
/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. Resource name of the space.
 *  Format: `spaces/{space}`.
 *  `{space}` is the resource identifier for the space. It's a unique,
 *  server-generated ID and is case sensitive. For example, `jQCFfuBOdN5z`.
 *  For more information, see How Meet identifies a meeting
 *  space (https://developers.google.com/meet/api/guides/meeting-spaces#identify-meeting-space).
 */
// const name = 'abc123'

// Imports the Meet library
const {SpacesServiceClient} = require('@google-apps/meet').v2;

// Instantiates a client
const meetClient = new SpacesServiceClient();

async function callEndActiveConference() {
  // Construct request
  const request = {
    name,
  };

  // Run request
  const response = await meetClient.endActiveConference(request);
  console.log(response);
}

callEndActiveConference();

Python

packages/google-apps-meet/samples/generated_samples/meet_v2_generated_spaces_service_end_active_conference_async.py
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.apps import meet_v2


async def sample_end_active_conference():
    # Create a client
    client = meet_v2.SpacesServiceAsyncClient()

    # Initialize request argument(s)
    request = meet_v2.EndActiveConferenceRequest(
        name="name_value",
    )

    # Make the request
    await client.end_active_conference(request=request)

Thay thế giá trị tên không gian bằng mã nhận dạng duy nhất do máy chủ tạo cho không gian họp.