Guardian
리소스는 학생의 과정 및 과정에 관한 정보를 받는 사용자(예: 학부모)를 나타냅니다. 일반적으로 학생의 클래스룸 도메인에 속하지 않는 보호자는 이메일 주소를 사용하여 초대해야 합니다.
초대는 GuardianInvitation
리소스로 표시됩니다. 초대를 받은 사용자는 수락을 요청하는 이메일을 받게 됩니다. 이메일 주소가 Google 계정과 연결되어 있지 않은 경우 사용자에게 초대를 수락하기 전에 계정을 만들라는 메시지가 표시됩니다.
사용자가 초대되고 초대를 수락하기 전에 GuardianInvitation
의 상태는 PENDING
입니다. 사용자가 초대를 수락하면 GuardianInvitation
가 COMPLETED
로 표시되고 Guardian
리소스가 생성됩니다.
GuardianInvitation
상태는 만료되거나 승인된 사용자가 초대를 취소하면(예: PatchGuardianInvitation
메서드 사용) COMPLETED
로 변경될 수도 있습니다. 보호자, 클래스룸 선생님 또는 관리자가 클래스룸 웹 애플리케이션 또는 DeleteGuardian
메서드를 사용하여 보호자 관계를 해제할 수도 있습니다.
보호자를 관리할 수 있는 사용자
다음 표에서는 인증된 사용자 유형에 따라 보호자와 관련하여 수행할 수 있는 작업을 설명합니다.
범위
보호자를 관리할 수 있는 범위는 세 가지가 있습니다.
https://www.googleapis.com/auth/classroom.guardianlinks.me.readonly
: 사용자의 보호자를 확인합니다.https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly
: 사용자가 가르치거나 관리하는 학생의 보호자 및 보호자 초대를 확인합니다.https://www.googleapis.com/auth/classroom.guardianlinks.students
: 사용자가 가르치거나 관리하는 학생의 보호자 및 보호자 초대를 확인하고 관리합니다.
대표적인 작업
이 섹션에서는 Google 클래스룸 API를 사용하여 실행할 수 있는 몇 가지 일반적인 보호자 작업을 설명합니다.
보호자 초대 만들기
다음 예는 userProfiles.guardianInvitations.create()
메서드를 사용하여 보호자 초대를 만드는 방법을 보여줍니다.
guardianInvitation = {
'invitedEmailAddress': 'guardian@gmail.com',
}
guardianInvitation = service.userProfiles().guardianInvitations().create(
studentId='student@mydomain.edu',
body=guardianInvitation).execute()
print("Invitation created with id: {0}".format(guardianInvitation.get('invitationId')))
응답에는 GuardianInvitation
를 참조하는 데 사용할 수 있는 서버 할당 식별자가 포함됩니다.
보호자 초대 취소하기
초대를 취소하려면 userProfiles.guardianInvitations.patch()
메서드를 호출하여 초대 상태를 PENDING
에서 COMPLETE
로 수정합니다.
초대를 삭제하는 유일한 방법입니다.
guardian_invite = {
'state': 'COMPLETE'
}
guardianInvitation = service.userProfiles().guardianInvitations().patch(
studentId='student@mydomain.edu',
invitationId=1234, # Replace with the invitation ID of the invitation you want to cancel
updateMask='state',
body=guardianInvitation).execute()
특정 학생의 초대 목록 보기
userProfiles.guardianInvitations.list()
메서드를 사용하여 특정 학생에게 전송된 모든 초대의 목록을 가져올 수 있습니다. 기본적으로 PENDING
초대만 반환됩니다. 도메인 관리자는 states
매개변수를 제공하여 COMPLETED
상태의 초대를 검색할 수도 있습니다.
guardian_invites = []
page_token = None
while True:
response = service.userProfiles().guardianInvitations().list(
studentId='student@mydomain.edu').execute()
guardian_invites.extend(response.get('guardian_invites', []))
page_token = response.get('nextPageToken', None)
if not page_token:
break
if not courses:
print('No guardians invited for this {0}.'.format(response.get('studentId')))
else:
print('Guardian Invite:')
for guardian in guardian_invites:
print('An invite was sent to '.format(guardian.get('id'),
guardian.get('guardianId')))
활성 보호자 목록
특정 학생의 활성 보호자가 누구인지 확인하려면 userProfiles.guardians.list()
메서드를 사용하세요. 활성 보호자는 초대를 수락한 보호자입니다.
guardian_invites = []
page_token = None
while True:
response = service.userProfiles().guardians().list(studentId='student@mydomain.edu').execute()
guardian_invites.extend(response.get('guardian_invites', []))
page_token = response.get('nextPageToken', None)
if not page_token:
break
if not courses:
print('No guardians invited for this {0}.'.format(response.get('studentId')))
else:
print('Guardian Invite:')
for guardian in guardian_invites:
print('An invite was sent to '.format(guardian.get('id'),
guardian.get('guardianId')))
보호자 삭제
userProfiles.guardians.delete()
메서드를 사용하여 학생에서 보호자를 삭제할 수도 있습니다.
service.userProfiles().guardians().delete(studentId='student@mydomain.edu',
guardianId='guardian@gmail.com').execute()