- Notifications
You must be signed in to change notification settings - Fork673
-
I want to archive a group's all projects,But get error: https://python-gitlab.readthedocs.io/en/v3.14.0/faq.html#attribute-error-list'GroupProject'objecthasnoattribute'archive'<class'gitlab.v4.objects.projects.GroupProject'>wascreatedviaalist()callandonlyasubsetofthedatamaybepresent.Toensurealldataispresentgettheobjectusingaget(object.id)call.Formoredetails,see:https://python-gitlab.readthedocs.io/en/v3.14.0/faq.html#attribute-error-list python3 codes is here: importosimportgitlabGIT_URL=os.getenv("GIT_URL","your_gitlab_url")PRIVATE_TOKEN=os.getenv("PRIVATE_TOKEN","you_token")client=gitlab.Gitlab(GIT_URL,private_token=PRIVATE_TOKEN)# Define a group under which all project are the project you want to archivegroup_name='my_group_name'group=client.groups.get(group_name)# Archive all projects in the groupforprojectingroup.projects.list(get_all=True):# project_id = project.id# project_name = project.name# print(project_id, project_name)try:project.archive()exceptExceptionase:print(e) what's wrong with it? |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 2 replies
-
You were almost there. The error message points you to the FAQ, and the entry you're looking for is this: You need to create a Project object, you cannot manipulate a GroupProject object directly. You can create a lazy object to save API calls. See: importosimportgitlabGIT_URL=os.getenv("GIT_URL","your_gitlab_url")PRIVATE_TOKEN=os.getenv("PRIVATE_TOKEN","you_token")client=gitlab.Gitlab(GIT_URL,private_token=PRIVATE_TOKEN)# Define a group under which all project are the project you want to archivegroup_name='my_group_name'group=client.groups.get(group_name)# Archive all projects in the groupforgroup_projectingroup.projects.list(get_all=True):project=client.projects.get(group_project.id,lazy=True)# project_id = project.id# project_name = project.name# print(project_id, project_name)try:project.archive()exceptExceptionase:print(e) |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2
-
I didn't understand just now, but after your help, I understand. Thank you |
BetaWas this translation helpful?Give feedback.
All reactions
-
Ahh, thanks a lot! I also got it running now! 👍🏼 |
BetaWas this translation helpful?Give feedback.