Module: Josef::GoogleWorkspace::Group
Instance Method Summary
collapse
Methods included from Members
#add_member, #del_member, #member_mail_addreses, #members_by
Methods included from Config
#actor, #actor!, #credential_path, #domains, #token_path
Instance Method Details
#create_group(group_mail_address) ⇒ Object
28
29
30
31
32
|
# File 'lib/josef/google_workspace/group.rb', line 28
def create_group(group_mail_address)
group = ::Google::Apis::AdminDirectoryV1::Group.new(email: group_mail_address)
client.insert_group(group)
end
|
#delete_group(group_mail_address) ⇒ Object
34
35
36
37
38
|
# File 'lib/josef/google_workspace/group.rb', line 34
def delete_group(group_mail_address)
group = groups.find{|g| g.email == group_mail_address}
client.delete_group(group.id)
end
|
#groups ⇒ Object
8
9
10
|
# File 'lib/josef/google_workspace/group.rb', line 8
def groups
@_groups ||= groups!
end
|
#groups! ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/josef/google_workspace/group.rb', line 12
def groups!
domains.map do | domain |
res = client.list_groups(domain: domain)
domain_groups = res.groups
next_page_token = res.next_page_token
while next_page_token.nil?.!
res = client.list_groups(domain: domain, page_token: next_page_token)
next_page_token = res.next_page_token
domain_groups.concat(res.groups)
end
domain_groups
end.flatten.compact
end
|