3 @qhcb0@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$dde eZ?Gd%d!d!eZ@Gd&d"d"e eZAGd'ddeZBGd(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)GroupWikiManagerGroup GroupManagerGroupDescendantGroupGroupDescendantGroupManager GroupSubgroupGroupSubgroupManagerc@seZdZdZdjZejddkejej d9d:Z ejddlejej d=d>Z ejddmejej dBdCZejddndoejejdpdEdFZejdejej dGdHZejddqdrejej dsdKdLZejddtejejdMdNZdDS)ur&nameaccessrequestsr audit_eventsrbadgesrbillable_membersrboardsrcustomattributesrdescendant_groupsr)exportsrepicsrhooksrimportsrissuesrissues_statisticsr#labelsrmembersr members_allr mergerequestsr milestonesrnotificationsettingsrpackagesr projectsr!runnersr" subgroupsr+ variablesr$clustersr deploytokensrwikisr% to_project_idcKs$d|j|f}|jjj|f|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)selfrHkwargspathrPW/home/ec2-user/environment/venv/lib/python3.6/dist-packages/gitlab/v4/objects/groups.pytransfer_projectLs zGroup.transfer_projectscopesearchcKs0||d}d|j}|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. )rSrTz/groups/%s/searchZ query_data)get_idrJrKZ http_list)rMrSrTrNdatarOrPrPrQrT\s  z Group.searchcn group_accessprovidercKs6d|j}|||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 z/groups/%s/ldap_group_links)rWrXrY post_dataN)rUrJrKrL)rMrWrXrYrNrOrVrPrPrQadd_ldap_group_linkqs  zGroup.add_ldap_group_linkNcKs>d|j}|dk r |d|7}|d|7}|jjj|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 z/groups/%s/ldap_group_linksNz/%s)rUrJrK http_delete)rMrWrYrNrOrPrPrQdelete_ldap_group_links    zGroup.delete_ldap_group_linkcKs"d|j}|jjj|f|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_syncN)rUrJrKrL)rMrNrOrPrPrQ ldap_syncs zGroup.ldap_syncgroup_id expires_atcKs6d|j}|||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)r_rXr`rZN)rUrJrKrL)rMr_rXr`rNrOrVrPrPrQshares  z Group.sharecKs&d|j|f}|jjj|f|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/%sN)rUrJrKr\)rMr_rNrOrPrPrQunshares z Group.unsharer-r r.rr/rr0rr1rr2rr3r)r4rr5rr6rr7rr8rr9r#r:rr;rr<rr=rr>rr?rr@r rAr!rBr"rCr+rDr$rErrFrrGr%)rcrdrerfrgrhrirjrkrlrmrnrorprqrrrsrtrurvrwrxryrzr{r|r})rH)rSrT)rWrXrY)rW)rY)N)r_rX)r`)N)r_)__name__ __module__ __qualname__Z_short_print_attrZ _managersrZregister_custom_actionexc on_http_errorZGitlabTransferProjectErrorrRZGitlabSearchErrorrTZGitlabCreateErrorr[ZGitlabDeleteErrorr]r^rarbrPrPrPrQr&,sX        c@sReZdZdZeZd)Zed*d+d Zed,d$Z e j e j d%Z ejejd-d'd(Zd&S).r'z/groups skip_groups all_availablerTorder_bysort statisticsownedwith_custom_attributesmin_access_leveltop_level_onlyr,rO 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)requiredoptionalfile_template_project_idprevent_forking_outside_groupshared_runners_setting)r)rrNcKs@dd|dfi}||d}|dk r(||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)rOr,Nr/groups/import)rZfiles)r)rKrL)rMrrOr,rrNrrVrPrPrQ import_groups  zGroupManager.import_group) rrrTrrrrrrr)r,rO)rrrrrrrrrrrrrrrrrr)r,rOrrrrrrrrrrrrrrrrrrrr)N)r~rr_pathr&_obj_cls _list_filtersrZ _create_attrsZ _update_attrsrZImageAttribute ListAttribute_typesrrZGitlabImportErrorrrPrPrPrQr'st c@s eZdZdS)r*N)r~rrrPrPrPrQr*.sc @s*eZdZdZeZddiZdZdej iZ d S)r+z/groups/%(group_id)s/subgroupsr_rIrrrTrrrrrrN) rrrTrrrrrr) r~rrrr*rZ_from_parent_attrsrrrrrPrPrPrQr+2sc@s eZdZdS)r(N)r~rrrPrPrPrQr(Dsc@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~rr__doc__rr(rrPrPrPrQr)HsN)DrKrrrrZ gitlab.baserrrZ gitlab.mixinsrr r r Zaccess_requestsr r.rr/rr1rrErZcustom_attributesrZ deploy_tokensrr5rZ export_importrrr6rr8rr:rr;rrrZmerge_requestsrr>rZnotification_settingsrr@r rAr!rBr"rr#rDr$rGr%__all__r&r'r*r+r(r)rPrPrPrQsN                       $_