a *Na7 @sddlmZddlmZddlmZddlmZmZmZm Z ddl m Z m Z m Z mZmZmZmZmZmZddlmZddlmZmZdd lmZdd lmZmZmZdd lm Z m!Z!dd l"m#Z#m$Z$dd l%m&Z&ddl'm(Z(gdZ)GdddeZ*Gddde eZ+GdddeZ,Gddde eZ-Gdddeeeeee e Z.Gddde eZ/Gddde*Z0Gddde+Z1Gd d!d!eZ2Gd"d#d#eeZ3d$S)%)cli) exceptions)types)RequiredOptional RESTManager RESTObjectRESTObjectList) CRUDMixin ListMixinObjectDeleteMixinParticipantsMixin RetrieveMixin SaveMixinSubscribableMixinTimeTrackingMixin TodoMixin)$ProjectMergeRequestAwardEmojiManager) ProjectCommitProjectCommitManager)$ProjectMergeRequestDiscussionManager),ProjectMergeRequestResourceLabelEventManager0ProjectMergeRequestResourceMilestoneEventManager,ProjectMergeRequestResourceStateEventManager) ProjectIssueProjectIssueManager)"ProjectMergeRequestApprovalManager&ProjectMergeRequestApprovalRuleManager)ProjectMergeRequestNoteManager)"ProjectMergeRequestPipelineManager) MergeRequestMergeRequestManagerGroupMergeRequestGroupMergeRequestManagerProjectMergeRequestProjectMergeRequestManagerProjectDeploymentMergeRequest$ProjectDeploymentMergeRequestManagerProjectMergeRequestDiffProjectMergeRequestDiffManagerc@s eZdZdS)r N__name__ __module__ __qualname__r.r.{/private/var/folders/js/6pj4vh5d4zd0k6bxv74qrbhr0000gr/T/pip-target-22xwyzbs/lib/python/gitlab/v4/objects/merge_requests.pyr /sr c@s.eZdZdZeZdZejejejejdZ dS)r!z/merge_requests)stateorder_bysort milestoneviewlabelsZwith_labels_detailsZwith_merge_status_recheck created_aftercreated_before updated_afterupdated_beforescope author_idZauthor_username assignee_id approver_idsapproved_by_idsZ reviewer_idZreviewer_usernamemy_reaction_emoji source_branch target_branchsearchinwipnot environmentZdeployed_beforeZdeployed_after)r=r>rCr5N) r+r,r-_pathr _obj_cls _list_filtersr ListAttribute_typesr.r.r.r/r!3s!r!c@s eZdZdS)r"Nr*r.r.r.r/r"^sr"c@s2eZdZdZeZddiZdZej ej ej dZ dS)r#z#/groups/%(group_id)s/merge_requestsZgroup_idid)r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrD)r=r>r5N) r+r,r-rGr"rH_from_parent_attrsrIrrJrKr.r.r.r/r#bsr#c@s2eZdZdZdZedeej ddZ edeej ddZ edeej ddZ edeej d d Zeded eejdd dZedeejddZedeejddZedeejddZededeejdddZd S)r$iid) )Z approvalsr)Zapproval_rulesr)Z awardemojisr)Zdiffsr)) discussionsr)notesr) pipelinesr)Zresourcelabeleventsr)Zresourcemilestoneeventsr)ZresourcestateeventsrcKs8d|jj|f}|jjj|fi|}||dS)aCCancel merge when the pipeline succeeds. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabMROnBuildSuccessError: If the server could not handle the request z)%s/%s/cancel_merge_when_pipeline_succeedsNmanagerpathget_idgitlabhttp_put _update_attrs)selfkwargsrT server_datar.r.r/#cancel_merge_when_pipeline_succeedss z7ProjectMergeRequest.cancel_merge_when_pipeline_succeedscKsNd|jj|f}|jjj|fddi|}t|jj|jjd}t|t|S)aList issues that will close on merge." 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) Raises: GitlabAuthenticationError: If authentication is not correct GitlabListError: If the list could not be retrieved Returns: RESTObjectList: List of issues z%s/%s/closes_issuesas_listFparent) rSrTrUrV http_listr_parentrrrYrZrTZ data_listrSr.r.r/ closes_issuessz!ProjectMergeRequest.closes_issuescKsNd|jj|f}|jjj|fddi|}t|jj|jjd}t|t|S)aList the merge request commits. 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) Raises: GitlabAuthenticationError: If authentication is not correct GitlabListError: If the list could not be retrieved Returns: RESTObjectList: The list of commits z %s/%s/commitsr]Fr^) rSrTrUrVr`rrarrrbr.r.r/commitsszProjectMergeRequest.commitscKs*d|jj|f}|jjj|fi|S)aTList the merge request changes. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabListError: If the list could not be retrieved Returns: RESTObjectList: List of changes z %s/%s/changesrSrTrUrVZhttp_getrYrZrTr.r.r/changesszProjectMergeRequest.changes)shaNcKsLd|jj|f}i}|r$||d<|jjj|fd|i|}||dS)a1Approve the merge request. Args: sha (str): Head SHA of MR **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabMRApprovalError: If the approval failed z %s/%s/approverh post_dataNrSrTrUrVZ http_postrX)rYrhrZrTdatar[r.r.r/approves zProjectMergeRequest.approvecKs@d|jj|f}i}|jjj|fd|i|}||dS)aUnapprove the merge request. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabMRApprovalError: If the unapproval failed z%s/%s/unapproveriNrj)rYrZrTrkr[r.r.r/ unapprove s zProjectMergeRequest.unapprovecKs2d|jj|f}i}|jjj|fd|i|S)a%Attempt to rebase the source branch onto the target branch Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabMRRebaseError: If rebasing failed z %s/%s/rebaseri)rSrTrUrVrW)rYrZrTrkr.r.r/rebases zProjectMergeRequest.rebasecKs*d|jj|f}|jjj|fi|S)a Attempt to merge changes between source and target branches into `refs/merge-requests/:iid/merge`. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabGetError: If cannot be merged z%s/%s/merge_refrerfr.r.r/ merge_ref,s zProjectMergeRequest.merge_ref)merge_commit_messageshould_remove_source_branchmerge_when_pipeline_succeedsFcKshd|jj|f}i}|r$||d<|dur4||d<|r@d|d<|jjj|fd|i|}||dS)aLAccept the merge request. Args: merge_commit_message (bool): Commit message should_remove_source_branch (bool): If True, removes the source branch merge_when_pipeline_succeeds (bool): Wait for the build to succeed, then merge **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabMRClosedError: If the merge failed z %s/%s/mergerpNrqTrrrirR)rYrprqrrrZrTrkr[r.r.r/merge;szProjectMergeRequest.merge)N)NFF)r+r,r-Z_id_attrZ _managersrZregister_custom_actionexcZ on_http_errorZGitlabMROnBuildSuccessErrorr\ZGitlabListErrorrcrdrgtupleZGitlabMRApprovalErrorrlrmZGitlabMRRebaseErrorrnZGitlabGetErrorroZGitlabMRClosedErrorrsr.r.r.r/r$sH                  r$c@sLeZdZdZeZddiZedddZeddZ d Z e j e j e j e j d Z d S) r%z'/projects/%(project_id)s/merge_requests project_idrL)r@rAtitle) r< descriptionZtarget_project_idr5 milestone_idremove_source_branchallow_maintainer_to_pushsquash reviewer_ids)requiredoptional) rAr<rwrxZ state_eventr5ryrzZdiscussion_lockedr{r|r})r)r0r1r2r3r4r5r6r7r8r9r:iidsr;r<r=r>r?r@rArBrD)r=r>rr5N)r+r,r-rGr$rHrMrZ _create_attrsrXrIrrJrKr.r.r.r/r%gs r%c@s eZdZdS)r&Nr*r.r.r.r/r&sr&c@seZdZdZeZdddZdS)r'zE/projects/%(project_id)s/deployments/%(deployment_id)s/merge_requestsrLrv)Z deployment_idrvN)r+r,r-rGr&rHrMr.r.r.r/r'sr'c@s eZdZdS)r(Nr*r.r.r.r/r(sr(c@seZdZdZeZdddZdS)r)z;/projects/%(project_id)s/merge_requests/%(mr_iid)s/versionsrvrN)rvZmr_iidN)r+r,r-rGr(rHrMr.r.r.r/r)sr)N)4rVrrrtrZ gitlab.baserrrrZ gitlab.mixinsr r r r r rrrrZ award_emojisrrdrrrOreventsrrrZissuesrrZmerge_request_approvalsrrrPrrQr__all__r r!r"r#r$r%r&r'r(r)r.r.r.r/s@   ,    +! eA