Forum Discussion
Kelemvor
Expert
That only works for the immediate group. I need subgroups included as well. Since websites don't contain the FullPath field like resources do, I don't think there is any way to do this.
Anonymous
7 months agoYeah, you'd just have to loop through all groups:
website_groups = lm.get_website_group_list(size=1000).items
for group in website_groups:
websites = lm.get_website_list(size=1000, filter=f"groupId:{group.id}").items
print(f"{group.full_path}: {','.join([x.name for x in websites])}")
- Anonymous7 months ago
One liner if you play code golf:
for group in lm.get_website_group_list(size=1000).items: print(f"{group.full_path}: {','.join([x.name for x in lm.get_website_list(size=1000, filter=f'groupId:{group.id}').items])}")
- Anonymous7 months ago
If you want the list per root group:
all_websites = {group.full_path: ','.join([x.name for x in lm.get_website_list(size=1000, filter=f'groupId:{group.id}').items]) for group in lm.get_website_group_list(size=1000).items} by_root_group = {} for full_path, websites in all_websites.items(): rootpath = full_path.split("/")[0] if rootpath in by_root_group.keys(): by_root_group[rootpath] += websites else: by_root_group[rootpath] = websites for k,v in by_root_group.items(): print(f"{k}: {v}")
Related Content
- 2 years ago
- 2 months ago