Forum Discussion
Anonymous
This should be getting better soon as websites are slated to be moved to the resources page "soon" and would be treated like any other object there.
As for getting the list under a group, you just need the group id then make a call to the api to get the list. Use the SDK and lmwrapper for this.
websites = lm.get_website_list(size=1000, filter="groupId:74").items
Where 74 is the id of the group in question.
Kelemvor
8 months agoExpert
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.
- Anonymous8 months ago
Yeah, 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])}")
- Anonymous8 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])}")
- Anonymous8 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
- 3 months ago