a *Nab0@sddlmZddlmZddlmZddlmZmZmZddl m Z m Z m Z m Z ddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:ddl;mGd d!d!e eZ?Gd"d#d#eZ@Gd$d%d%e eZAGd&d'd'eZBGd(d)d)eAZCd*S)+)cli) exceptions)types)RequiredOptional RESTManager RESTObject) CRUDMixin ListMixinObjectDeleteMixin SaveMixin)GroupAccessRequestManager)GroupAuditEventManager)GroupBadgeManager)GroupBoardManager)GroupClusterManager)GroupCustomAttributeManager)GroupDeployTokenManager)GroupEpicManager)GroupExportManagerGroupImportManager)GroupHookManager)GroupIssueManager)GroupLabelManager)GroupBillableMemberManagerGroupMemberAllManagerGroupMemberManager)GroupMergeRequestManager)GroupMilestoneManager) GroupNotificationSettingsManager)GroupPackageManager)GroupProjectManager)GroupRunnerManager)GroupIssuesStatisticsManager)GroupVariableManager)GroupWikiManager)Group GroupManagerGroupDescendantGroupGroupDescendantGroupManager GroupSubgroupGroupSubgroupManagerc@seZdZdZdZeddeej ddZ eddeej ddZ edd eej d d Zedd d eejdddZedeej ddZedddeej dddZeddeejddZdS)r&name))Zaccessrequestsr ) audit_eventsr)badgesr)Zbillable_membersr)boardsr)Zcustomattributesr)Zdescendant_groupsr))exportsr)epicsr)hooksr)Zimportsr)issuesr)Zissues_statisticsr#)labelsr)membersr)Z members_allr)Z mergerequestsr) milestonesr)Znotificationsettingsr)packagesr )projectsr!)runnersr")Z subgroupsr+) variablesr$)clustersr)Z deploytokensr)wikisr%) to_project_idcKs(d|j|f}|jjj|fi|dS)afTransfer a project to this group. Args: to_project_id (int): ID of the project to transfer **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabTransferProjectError: If the project could not be transfered z/groups/%s/projects/%sN)idmanagergitlab http_post)selfr=kwargspathrEs/private/var/folders/js/6pj4vh5d4zd0k6bxv74qrbhr0000gr/T/pip-target-22xwyzbs/lib/python/gitlab/v4/objects/groups.pytransfer_projectLs zGroup.transfer_projectscopesearchcKs0||d}d|}|jjj|fd|i|S)aSearch the group resources matching the provided string.' Args: scope (str): Scope of the search search (str): Search string **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabSearchError: If the server failed to perform the request Returns: GitlabList: A list of dicts describing the resources found. rHz/groups/%s/searchZ query_data)get_idr?r@Z http_list)rBrIrJrCdatarDrErErFrJ\s  z Group.searchcn group_accessprovidercKs6d|}|||d}|jjj|fd|i|dS)aAdd an LDAP group link. Args: cn (str): CN of the LDAP group group_access (int): Minimum access level for members of the LDAP group provider (str): LDAP provider for the LDAP group **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server cannot perform the request /groups/%s/ldap_group_linksrM post_dataNrKr?r@rA)rBrNrOrPrCrDrLrErErFadd_ldap_group_linkqs  zGroup.add_ldap_group_link)rN)rPNcKs>d|}|dur |d|7}|d|7}|jj|dS)aDelete an LDAP group link. Args: cn (str): CN of the LDAP group provider (str): LDAP provider for the LDAP group **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabDeleteError: If the server cannot perform the request rQNz/%srKr?r@Z http_delete)rBrNrPrCrDrErErFdelete_ldap_group_links    zGroup.delete_ldap_group_linkcKs&d|}|jjj|fi|dS)aSync LDAP groups. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server cannot perform the request z/groups/%s/ldap_syncNrS)rBrCrDrErErF ldap_syncs zGroup.ldap_sync)group_idrO) expires_atcKs6d|}|||d}|jjj|fd|i|dS)aShare the group with a group. Args: group_id (int): ID of the group. group_access (int): Access level for the group. **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server failed to perform the request z/groups/%s/share)rXrOrYrRNrS)rBrXrOrYrCrDrLrErErFshares  z Group.share)rXcKs*d||f}|jjj|fi|dS)aYDelete a shared group link within a group. Args: group_id (int): ID of the group. **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabDeleteError: If the server failed to perform the request z/groups/%s/share/%sNrU)rBrXrCrDrErErFunshares z Group.unshare)N)N)__name__ __module__ __qualname__Z_short_print_attrZ _managersrZregister_custom_actionexc on_http_errorZGitlabTransferProjectErrorrGZGitlabSearchErrorrJZGitlabCreateErrorrTZGitlabDeleteErrorrVrWrZr[rErErErFr&,s.                r&c@sReZdZdZeZdZedddZeddZ e j e j dZ eejd d d Zd S) r'z/groups) skip_groups all_availablerJorder_bysort statisticsownedwith_custom_attributesmin_access_levelZtop_level_only)r,rD) descriptionmembership_lock visibilityshare_with_group_lock!require_two_factor_authenticationtwo_factor_grace_periodproject_creation_levelauto_devops_enabledsubgroup_creation_levelemails_disabledavatarmentions_disabled lfs_enabledrequest_access_enabled parent_iddefault_branch_protectionshared_runners_minutes_limit"extra_shared_runners_minutes_limit)requiredoptional)r,rDrirjrlrkrmrnrorprqrrrsrtrurvrxZfile_template_project_idryrzZprevent_forking_outside_groupZshared_runners_setting)r|)rsraNcKs@dd|dfi}||d}|dur(||d<|jjd ||d|S) aImport a group from an archive file. Args: file: Data or file object containing the group path (str): The path for the new group to be imported. name (str): The name for the new group. parent_id (str): ID of a parent group that the group will be imported into. **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabImportError: If the server failed to perform the request Returns: dict: A representation of the import status. filez file.tar.gzzapplication/octet-stream)rDr,Nrw/groups/import)rRfiles)r~)r@rA)rBr}rDr,rwrCrrLrErErF import_groups zGroupManager.import_group)N)r\r]r^_pathr&_obj_cls _list_filtersrZ _create_attrsZ _update_attrsrZImageAttribute ListAttribute_typesr_r`ZGitlabImportErrorrrErErErFr's  r'c@s eZdZdS)r*Nr\r]r^rErErErFr*.sr*c@s*eZdZdZeZddiZdZdej iZ dS)r+z/groups/%(group_id)s/subgroupsrXr>) rarbrJrcrdrerfrgrhraN) r\r]r^rr*rZ_from_parent_attrsrrrrrErErErFr+2s  r+c@s eZdZdS)r(NrrErErErFr(Dsr(c@seZdZdZdZeZdS)r)z This manager inherits from GroupSubgroupManager as descendant groups share all attributes with subgroups, except the path and object class. z&/groups/%(group_id)s/descendant_groupsN)r\r]r^__doc__rr(rrErErErFr)Hsr)N)Dr@rrr_rZ gitlab.baserrrZ gitlab.mixinsrr r r Zaccess_requestsr r-rr.rr/rr;rZcustom_attributesrZ deploy_tokensrr1rZ export_importrrr2rr3rr4rr5rrrZmerge_requestsrr6rZnotification_settingsrr7r r8r!r9r"rer#r:r$r<r%__all__r&r'r*r+r(r)rErErErFsD                        $_