
    ,Of'"                        d dl mZ d dlmZmZ d dlZd dlZd dlZd dl	Zd dl
Zd dlmZmZmZmZ d dlmZ erd dlmZ d dlmZ d dl	mZ d d	l
mZ  G d
 dej*                  j,                        Zy)    )annotations)TYPE_CHECKINGAnyN)	AttributeNotSetOpt
is_defined)PaginatedList)	NamedUser)RequiredPullRequestReviews)RequiredStatusChecks)Teamc                      e Zd ZdZddZddZedd       Zedd       Zedd       Z	edd       Z
edd       Zedd	       Zedd
       Zedd       Zedd       Zedd       ZddZddZddZy)BranchProtectionz
    This class represents Branch Protection.

    The reference can be found here
    https://docs.github.com/en/rest/reference/repos#get-branch-protection

    c                P    | j                  d| j                  j                  i      S )Nurl)get__repr___urlvalueselfs    7lib/python3.12/site-packages/github/BranchProtection.py__repr__zBranchProtection.__repr__=   s     		 899    c                4   t         | _        t         | _        t         | _        t         | _        t         | _        t         | _        t         | _        t         | _        t        j                  j                   | _        t         | _        t         | _        t         | _        y N)r   r   _allow_deletions_allow_force_pushes_allow_fork_syncing_lock_branch!_required_conversation_resolution_required_status_checks_enforce_adminsgithubGithubObject_required_linear_history_required_pull_request_reviews_user_push_restrictions_team_push_restrictionsr   s    r   _initAttributesz BranchProtection._initAttributes@   sm    $*	174: 4: -3BH.HN$069?9L9L9S9S%U[+17$17$r   c                d    | j                  | j                         | j                  j                  S r   )_completeIfNotSetr   r   r   s    r   allow_deletionsz BranchProtection.allow_deletionsN   s(    t445$$***r   c                d    | j                  | j                         | j                  j                  S r   )r,   r   r   r   s    r   allow_force_pushesz#BranchProtection.allow_force_pushesS   (    t778''---r   c                d    | j                  | j                         | j                  j                  S r   )r,   r   r   r   s    r   allow_fork_syncingz#BranchProtection.allow_fork_syncingX   r0   r   c                d    | j                  | j                         | j                  j                  S r   )r,   r    r   r   s    r   lock_branchzBranchProtection.lock_branch]   s(    t001  &&&r   c                d    | j                  | j                         | j                  j                  S r   )r,   r!   r   r   s    r    required_conversation_resolutionz1BranchProtection.required_conversation_resolutionb   s(    tEEF55;;;r   c                d    | j                  | j                         | j                  j                  S r   )r,   r   r   r   s    r   r   zBranchProtection.urlg   s"    tyy)yyr   c                d    | j                  | j                         | j                  j                  S r   )r,   r"   r   r   s    r   required_status_checksz'BranchProtection.required_status_checksl   s(    t;;<++111r   c                d    | j                  | j                         | j                  j                  S r   )r,   r#   r   r   s    r   enforce_adminszBranchProtection.enforce_adminsq   s(    t334##)))r   c                d    | j                  | j                         | j                  j                  S r   )r,   r&   r   r   s    r   required_linear_historyz(BranchProtection.required_linear_historyv   s(    t<<=,,222r   c                d    | j                  | j                         | j                  j                  S r   )r,   r'   r   r   s    r   required_pull_request_reviewsz.BranchProtection.required_pull_request_reviews{   s(    tBBC22888r   c                    t        | j                        sy t        t        j                  j                  | j
                  | j                  d       S r   )r	   r(   r
   r$   r   
_requesterr   s    r   get_user_push_restrictionsz+BranchProtection.get_user_push_restrictions   sB    $667&&OO((	
 	
r   c                    t        | j                        sy t        j                  j                  t        j                  j                  | j
                  | j                  d       S r   )r	   r)   r$   r
   r   rA   r   s    r   get_team_push_restrictionsz+BranchProtection.get_team_push_restrictions   sF    $667##11&++2B2BDOOUYUqUqswxxr   c                   d|v r| j                  |d   d         | _        d|v r| j                  |d   d         | _        d|v r| j                  |d   d         | _        d|v r| j                  |d   d         | _        d|v r| j                  |d   d         | _        d|v r| j                  |d         | _        d|v r2| j                  t        j                  j                  |d         | _        d	|v r| j                  |d	   d         | _        d
|v r2| j                  t        j                  j                  |d
         | _        d|v r| j                  |d   d         | _        d|v r|d   d   | _        |d   d   | _        y y )Nr-   enabledr/   r2   r4   r6   r   r9   r;   r?   r=   restrictions	users_url	teams_url)_makeBoolAttributer   r   r   r    r!   _makeStringAttributer   _makeClassAttributer$   r   r"   r#   r   r'   r&   r(   r)   )r   
attributess     r   _useAttributeszBranchProtection._useAttributes   s   
*$($;$;JGX<YZc<d$eD!:-'+'>'>zJ^?_`i?j'kD$:-'+'>'>zJ^?_`i?j'kD$J& $ 7 7
=8QR[8\ ]D-;595L5L=>yI6D2 J11*U2CDDI#z1+/+C+C++@@34,D( z)#'#:#::FV;WXa;b#cD *j8262J2J11LL:;3D/ %
2,0,C,CJOhDijsDt,uD)Z'+5n+Ek+RD(+5n+Ek+RD( (r   N)returnstr)rO   None)rO   bool)rO   r   )rO   r   )rO   zPaginatedList[NamedUser] | None)rO   zPaginatedList[Team] | None)rM   zdict[str, Any]rO   rQ   )__name__
__module____qualname____doc__r   r*   propertyr-   r/   r2   r4   r6   r   r9   r;   r=   r?   rB   rD   rN    r   r   r   r   4   s    :8 + + . . . . ' ' < <   2 2 * * 3 3 9 9
y
Sr   r   )
__future__r   typingr   r   github.GithubObjectr$   github.NamedUser!github.RequiredPullRequestReviewsgithub.RequiredStatusChecksgithub.Teamr   r   r   r	   github.PaginatedListr
   r   r   r   r   r%   CompletableGithubObjectr   rX   r   r   <module>rb      sQ   B # %   ( "  B B .*L@ zSv**BB zSr   