atlassian-python-api icon indicating copy to clipboard operation
atlassian-python-api copied to clipboard

[Conflence] List for the names of all confluence spaces

Open mert-kurttutan opened this issue 1 year ago • 5 comments

Hi, Thanks for the project !!! Is it possible to get list of names of all spaces in confluence. I could not find the function for this.

mert-kurttutan avatar Dec 16 '24 13:12 mert-kurttutan

I think we should block this account. But, just for clarification. I thought of this solution, too, but it takes unnecessarily long since it downloads the entire space content instead of just the space name, which is exactly what I want.

Edit: There was a bot spamming PR in response to issues, which now seems to be banned (Good Job Github Support Team !!!!)

mert-kurttutan avatar Dec 16 '24 14:12 mert-kurttutan

So, I want to only the names to be downloaded

mert-kurttutan avatar Dec 16 '24 14:12 mert-kurttutan

It turns oout that there is an endpoint that gives this: ``../rest/spacedirectory/1/search"`. If you want I can implement PR for this.

mert-kurttutan avatar Dec 17 '24 07:12 mert-kurttutan

def get_spaces(confluence, url:str):
spaces = confluence.get_all_spaces(start=0, limit=500, expand=None) # get spaces, select global spaces

test_spaces = []
global_spaces = []
personal_spaces = []

for spc in spaces["results"]:

    space_dict = {
            "name": spc['name'],
            "key": spc["key"],
            "url": url + spc["_links"]["webui"],
    }

    if spc["type"] == "personal":
        space_dict["type"] = "personal"
        personal_spaces.append(space_dict)
    if spc["type"] == "global":
        # space_path = path + spc['key']
        # if not os.path.exists(space_path):
        #     os.mkdir(space_path)
        space_dict["type"] = "global"
        personal_spaces.append(space_dict)
        global_spaces.append(space_dict)
        if spc['key'] == "LLMTest":
            
            test_spaces.append(space_dict)

spaces = [] # empty
return global_spaces, personal_spaces, test_spaces

MonoMarkor avatar Jul 17 '25 08:07 MonoMarkor

@mert-kurttutan @MonoMarkor feel free to send as PR

gonchik avatar Aug 20 '25 22:08 gonchik