Google Chat 스페이스의 일정 나열하기

이 가이드에서는 list 사용 방법을 설명합니다. SpaceEvent 리소스의 메서드 스페이스의 리소스 변경사항을 나열합니다.

SpaceEvent 리소스 스페이스의 하위 리소스를 포함하여 대상 스페이스의 변경사항을 나타냅니다. 멤버십과 같은 다양한 유형의 콘텐츠를 공유할 수 있습니다. 자세한 내용은 지원되는 이벤트 유형 및 이벤트 페이로드 목록은 eventTypeSpaceEvent 리소스payload 필드 참조하세요.

요청 시점으로부터 최대 28일 전까지 이벤트를 나열할 수 있습니다. 서버 는 영향을 받은 리소스의 최신 버전이 포함된 이벤트를 반환합니다. 예를 들어 새 스페이스 멤버에 관한 이벤트를 나열하는 경우 서버에서 다음을 반환합니다. 최신 멤버십 세부정보가 포함된 리소스 Membership개 새 제품인 경우 요청된 기간 동안 구성원이 삭제된 경우, 이벤트 페이로드에 Membership 리소스가 비어 있습니다.

이 메서드를 호출하려면 user'와 인증에 대해 자세히 알아보세요. 받는사람 목록 이벤트의 경우 인증된 사용자가 스페이스의 멤버여야 합니다.

기본 요건

Python

스페이스 이벤트 나열

Chat 스페이스의 스페이스 이벤트를 나열하려면 다음 안내를 따르세요.

다음 코드 샘플에서는 새 멤버십에 대한 이벤트를 나열하고 메시지가 표시됩니다.

Python

  1. 작업 디렉터리에 chat_space_event_list.py라는 파일을 만듭니다.
  2. chat_space_event_list.py에 다음 코드를 포함합니다.

    """Lists SpaceEvent resources from the Chat API."""
    
    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.readonly",
    "https://www.googleapis.com/auth/chat.messages.readonly"]
    
    # 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().spaceEvents().list(
    
        # The space from which to list events.
        #
        # Replace SPACE with a space name.
        # Obtain the space name from the spaces resource of Chat API,
        # or from a space's URL.
        parent='spaces/SPACE',
    
        # A required filter. Filters and returns events about new memberships and messages
        filter='event_types:"google.workspace.chat.membership.v1.created" OR event_types:"google.workspace.chat.message.v1.created"'
    
    ).execute()
    
    # Prints details about the created space events.
    print(result)
    
  3. 코드에서 다음을 바꿉니다.

    • SPACE: 스페이스 이름으로, 다음에서 가져올 수 있습니다. spaces.list 메서드 Chat API 또는 스페이스의 URL에서 가져올 수 있습니다.
  4. 작업 디렉터리에서 샘플을 빌드하고 실행합니다.

    python3 chat_space_event_list.py
    

Chat API는 SpaceEvent 리소스 신규 멤버십 및 메시지 관련 이벤트

페이지로 나누기 맞춤설정

원하는 경우 다음 쿼리 매개변수를 전달하여 페이지로 나누기를 맞춤설정합니다.

  • pageSize: 반환할 SpaceEvent 리소스의 최대 개수입니다. 서비스는 이 값보다 더 적은 수의 값을 반환할 수 있습니다. 음수 값은 오류 INVALID_ARGUMENT
  • pageToken: 이전 목록 공간 이벤트 호출에서 수신된 페이지 토큰입니다. 후속 페이지를 검색하려면 이 토큰을 제공하세요. 페이지로 나누기 시 필터 값이 페이지 토큰을 제공한 호출과 일치해야 합니다. 예기치 않은 결과가 발생할 수 있습니다