3 @qhc8@s*ddlmZddlmZddlmZddlmZmZmZddl m Z m Z m Z m Z mZmZmZmZmZmZddlmZddlmZd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'gZGd(d d eeZGd)d d ee e eZGd*d d eeZGd+d d ee e eZGd,d d eeZGd-ddee e eZGd.ddeeZGd/dde eeZ Gd0ddeZ!Gd1dde eZ"Gd2ddeeeZ#Gd3dde eZ$Gd4ddeZ%Gd5ddeeZ&Gd6ddeeZ'Gd7ddee e eZ(Gd8ddeZ)Gd9ddeZ*Gd:dde eZ+Gd;ddeeZ,GdddeeZ/Gd?d d ee e eZ0Gd@d!d!e eZ1GdAd"d"eeZ2GdBd#d#eeZ3GdCd$d$eZ4GdDd%d%eeZ5GdEd&d&eZ6GdFd'd'ee eZ7GdGdHdHeeZ8GdIdJdJeeZ9dKS)L)cli) exceptions)types)RequiredOptional RESTManager RESTObject) CreateMixin CRUDMixin DeleteMixinGetWithoutIdMixin ListMixin NoUpdateMixinObjectDeleteMixin RetrieveMixin SaveMixin UpdateMixin)UserCustomAttributeManager)UserEventManagerCurrentUserEmailCurrentUserEmailManagerCurrentUserGPGKeyCurrentUserGPGKeyManagerCurrentUserKeyCurrentUserKeyManagerCurrentUserStatusCurrentUserStatusManager CurrentUserCurrentUserManagerUser UserManager ProjectUserProjectUserManager UserEmailUserEmailManagerUserActivities UserStatusUserStatusManagerUserActivitiesManager UserGPGKeyUserGPGKeyManagerUserKeyUserKeyManagerUserIdentityProviderManagerUserImpersonationTokenUserImpersonationTokenManagerUserMembershipUserMembershipManager UserProjectUserProjectManagerc@seZdZdZdS)remailN)__name__ __module__ __qualname___short_print_attrr9r9V/home/ec2-user/environment/venv/lib/python3.6/dist-packages/gitlab/v4/objects/users.pyr8sc@seZdZdZeZeddZdS)rz /user/emailsr4)requiredN)r4)r5r6r7_pathr_obj_clsr _create_attrsr9r9r9r:r<sc@s eZdZdS)rN)r5r6r7r9r9r9r:rBsc@seZdZdZeZeddZdS)rz/user/gpg_keyskey)r;N)r?)r5r6r7r<rr=rr>r9r9r9r:rFsc@seZdZdZdS)rtitleN)r5r6r7r8r9r9r9r:rLsc@seZdZdZeZeddZdS)rz /user/keysr@r?)r;N)r@r?)r5r6r7r<rr=rr>r9r9r9r:rPsc@seZdZdZdZdS)rNmessage)r5r6r7_id_attrr8r9r9r9r:rVsc@seZdZdZeZeddZdS)rz /user/statusemojirA)optionalN)rCrA)r5r6r7r<rr=r _update_attrsr9r9r9r:r[sc@seZdZdZdZdZdS)rNusernamestatusremailsrgpgkeysrkeysrrGrrHrrIrrJr)rKrLrMrN)r5r6r7rBr8 _managersr9r9r9r:ras c@seZdZdZeZdS)rz/userN)r5r6r7r<rr=r9r9r9r:rlsc @seZdZdZd3Zejdejej ddZ ejdejej ddZ ejdejej ddZejdejejd d!Zejdejejd"d#Zejdejejd$d%Zd&S)4rrFcustomattributesrrHr$followers_usersUserFollowersManagerfollowing_usersUserFollowingManagereventsrrIr*identityprovidersr-impersonationtokensr/rJr, membershipsr1projectsr3rGr'cKs2d|j}|jjj|f|}|dkr.d|jd<|S)aRBlock the user. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabBlockError: If the user could not be blocked Returns: bool: Whether the user status has been changed z/users/%s/blockTblockedstate)idmanagergitlab http_post_attrs)selfkwargspath server_datar9r9r:blocks   z User.blockcKsd|j}|jjj|f|S)aUFollow the user. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabFollowError: If the user could not be followed Returns: dict: The new object data (*not* a RESTObject) z/users/%s/follow)r\r]r^r_)rarbrcr9r9r:follows z User.followcKsd|j}|jjj|f|S)aYUnfollow the user. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabUnfollowError: If the user could not be followed Returns: dict: The new object data (*not* a RESTObject) z/users/%s/unfollow)r\r]r^r_)rarbrcr9r9r:unfollows z User.unfollowcKs2d|j}|jjj|f|}|dkr.d|jd<|S)aXUnblock the user. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabUnblockError: If the user could not be unblocked Returns: bool: Whether the user status has been changed z/users/%s/unblockTactiver[)r\r]r^r_r`)rarbrcrdr9r9r:unblocks   z User.unblockcKs.d|j}|jjj|f|}|r*d|jd<|S)a`Deactivate the user. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabDeactivateError: If the user could not be deactivated Returns: bool: Whether the user status has been changed z/users/%s/deactivateZ deactivatedr[)r\r]r^r_r`)rarbrcrdr9r9r: deactivates   zUser.deactivatecKs.d|j}|jjj|f|}|r*d|jd<|S)aZActivate the user. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabActivateError: If the user could not be activated Returns: bool: Whether the user status has been changed z/users/%s/activaterhr[)r\r]r^r_r`)rarbrcrdr9r9r:activates   z User.activateNrPrrHr$rQrRrSrTrUrrIr*rVr-rWr/rJr,rXr1rYr3rGr') rlrmrnrorprqrrrsrtrurvrw)r5r6r7r8rOrZregister_custom_actionexcZ on_http_errorZGitlabBlockErrorreZGitlabFollowErrorrfZGitlabUnfollowErrorrgZGitlabUnblockErrorriZGitlabDeactivateErrorrjZGitlabActivateErrorrkr9r9r9r:rqs2c@s<eZdZdZeZd%Zed&d Zed'd(d"Z e j e j d#Z d$S))r z/usersrhrZrF extern_uidproviderexternalsearchcustom_attributesrG two_factorr4namepasswordreset_passwordskypelinkedintwitterprojects_limitbioadmincan_create_group website_urlskip_confirmation organizationlocationavatar public_emailprivate_profilecolor_scheme_idtheme_id)rDskip_reconfirmation)r;rD)ZconfirmrN) rhrZrFryrzr{r|r}rGr~)r4rFrrrrrrrryrzrrrrrr{rrrrrrr)r4rFr)rrrrrryrzrrrrrr{rrrrrrr)r5r6r7r<rr= _list_filtersrr>rErZLowercaseStringAttributeZImageAttribute_typesr9r9r9r:r sxc@s eZdZdS)r!N)r5r6r7r9r9r9r:r!Csc@s*eZdZdZeZddiZdZdej iZ dS)r"z/projects/%(project_id)s/usersZ project_idr\r| skip_usersN)r|r) r5r6r7r<r!r=_from_parent_attrsrrZ ListAttributerr9r9r9r:r"Gs c@seZdZdZdS)r#r4N)r5r6r7r8r9r9r9r:r#Osc@s&eZdZdZeZddiZeddZdS)r$z/users/%(user_id)s/emailsuser_idr\r4)r;N)r4) r5r6r7r<r#r=rrr>r9r9r9r:r$Ssc@seZdZdZdS)r%rFN)r5r6r7rBr9r9r9r:r%Zsc@seZdZdZdZdS)r&NrA)r5r6r7rBr8r9r9r9r:r&^sc@seZdZdZeZddiZdS)r'z/users/%(user_id)s/statusrr\N)r5r6r7r<r&r=rr9r9r9r:r'csc@seZdZdZeZdS)r(z/user/activitiesN)r5r6r7r<r%r=r9r9r9r:r(isc@s eZdZdS)r)N)r5r6r7r9r9r9r:r)nsc@s&eZdZdZeZddiZeddZdS)r*z/users/%(user_id)s/gpg_keysrr\r?)r;N)r?) r5r6r7r<r)r=rrr>r9r9r9r:r*rsc@s eZdZdS)r+N)r5r6r7r9r9r9r:r+ysc@s&eZdZdZeZddiZeddZdS) r,z/users/%(user_id)s/keysrr\r@r?)r;N)r@r?) r5r6r7r<r+r=rrr>r9r9r9r:r,}sc@seZdZdZdZddiZdS)r-zManager for user identities. This manager does not actually manage objects but enables functionality for deletion of user identities by provider. z/users/%(user_id)s/identitiesrr\N)r5r6r7__doc__r<rr9r9r9r:r-sc@s eZdZdS)r.N)r5r6r7r9r9r9r:r.sc@s,eZdZdZeZddiZed d dZd Z d S) r/z'/users/%(user_id)s/impersonation_tokensrr\rscopes expires_at)r;rDr[N)rr)r)r[) r5r6r7r<r.r=rrr>rr9r9r9r:r/s  c@seZdZdZdS)r0Z source_idN)r5r6r7rBr9r9r9r:r0sc@s eZdZdZeZddiZdZdS)r1z/users/%(user_id)s/membershipsrr\typeN)r)r5r6r7r<r0r=rrr9r9r9r:r1sc@s eZdZdS)r2N)r5r6r7r9r9r9r:r2sc@s4eZdZdZeZddiZed(d)dZd*Z d%d&Z d'S)+r3z/projects/user/%(user_id)srr\rdefault_branchissues_enabled wall_enabledmerge_requests_enabled wiki_enabledsnippets_enabledpublic visibility descriptionbuilds_enabled public_builds import_url"only_allow_merge_if_build_succeeds)r;rDarchivedorder_bysortr|simpleowned membershipstarred statisticswith_issues_enabledwith_merge_requests_enabledwith_custom_attributeswith_programming_languagewiki_checksum_failedrepository_checksum_failedmin_access_levelid_after id_beforecKs6|jrd|jj}n d|d}tj|fd|i|S)aRetrieve a list of objects. Args: all (bool): If True, return all the items, without pagination per_page (int): Number of items to retrieve per request page (int): ID of the page to return (starts with page 1) as_list (bool): If set to False and no pagination option is defined, return a generator instead of a list **kwargs: Extra options to send to the server (e.g. sudo) Returns: list: The list of objects, or a generator if `as_list` is False Raises: GitlabAuthenticationError: If authentication is not correct GitlabListError: If the server cannot perform the request z/users/%s/projectsrrc)_parentr\r list)rarbrcr9r9r:rs zUserProjectManager.listN)r) rrrrrrrrrrrrr)rrrrr|rrrrrrrrrrrrrr) r5r6r7r<r2r=rrr>rrr9r9r9r:r3sLc@seZdZdZeZddiZdS)rRz/users/%(user_id)s/followersrr\N)r5r6r7r<rr=rr9r9r9r:rRsrRc@seZdZdZeZddiZdS)rTz/users/%(user_id)s/followingrr\N)r5r6r7r<rr=rr9r9r9r:rTsrTN):r^rrrxrZ gitlab.baserrrZ gitlab.mixinsrr r r r r rrrrr}rrUr__all__rrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3rRrTr9r9r9r:s   0    H  E