
    #Ii'                         S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  S SKJr  S S	KJr   " S
 S5      rg)    N)Consts)AppAuth)	GithubApp)GithubException)Installation)InstallationAuthorization)PaginatedList)	Requesterc                   r   \ rS rSrSrSS\R                  4\R                  \R                  \R                  SSS\R                  \R                  \R                  SS.
S jjrS rS rS	 r\R"                  " S
5      SS j5       rSS jr\R"                  " S5      S 5       rS rS rS rS rS rS rSrg)GithubIntegration   z7
Main class to obtain tokens for a GitHub integration.
NT)
timeout
user_agentper_pageverifyretry	pool_size
jwt_expiryjwt_issued_atjwt_algorithmauthc       
            Ub"  [        U[        [        45      (       d   U5       eUb  [        U[        5      (       d   S5       e[        U[        5      (       d   U5       e[        U[        5      (       d   U5       eUb  [        U[        5      (       d   U5       e[        U[        5      (       d   U5       e[        U[        [        45      (       d   U5       eUbE  [        U[        5      (       d0  [        U[        R
                  R                  5      (       d   U5       eU	b  [        U	[        5      (       d   U	5       e[        U
[        5      (       d   U
5       e[        R                  U
s=::  a  [        R                  ::  d   U
5       e   U
5       e[        U[        5      (       d   eX0l
        Uc?  Uc<  U
[        R                  :w  d(  U[        R                  :w  d  U[        R                  :w  a&  [        R                  " S[         S9  [#        UUU
UUS9n[        U["        5      (       d   S[%        U5       35       eXl        [)        UU R                  UUUUUU	S9U l        g)a  
:param integration_id: int deprecated, use auth=github.Auth.AppAuth(...) instead
:param private_key: string deprecated, use auth=github.Auth.AppAuth(...) instead
:param base_url: string
:param timeout: integer
:param user_agent: string
:param per_page: int
:param verify: boolean or string
:param retry: int or urllib3.util.retry.Retry object
:param pool_size: int
:param jwt_expiry: int deprecated, use auth=github.Auth.AppAuth(...) instead
:param jwt_issued_at: int deprecated, use auth=github.Auth.AppAuth(...) instead
:param jwt_algorithm: string deprecated, use auth=github.Auth.AppAuth(...) instead
:param auth: authentication method
Nz'supplied private key should be a stringzArguments integration_id, private_key, jwt_expiry, jwt_issued_at and jwt_algorithm are deprecated, please use auth=github.Auth.AppAuth(...) instead)category)r   r   r   zCGithubIntegration requires github.Auth.AppAuth authentication, not )r   base_urlr   r   r   r   r   r   )
isinstanceintstrboolurllib3utilRetryr   MIN_JWT_EXPIRYMAX_JWT_EXPIRYr   DEFAULT_JWT_EXPIRYDEFAULT_JWT_ISSUED_ATDEFAULT_JWT_ALGORITHMwarningswarnDeprecationWarningr   typer   r
   _GithubIntegration__requester)selfintegration_idprivate_keyr   r   r   r   r   r   r   r   r   r   r   s                 >/venv/lib/python3.13/site-packages/github/GithubIntegration.py__init__GithubIntegration.__init__   s^   @ %nsCj99I>I9"S  989  (C((2(2('3''00'!Z
C%@%@L*L@(C((2(2(&4+..66.M%%%%!3!344	 		5  Jy#$>$>I	I>*c**6J6*$$
Kf6K6KKWZWKWZWK-----  &&V666 < << < <<MMC+
 %++D '
 
 	^PQUVZQ[P\]	^ 
 	$]]!	
    c                     U R                   R                  XR                  S9n[        R                  " S0 U R                  R                  U5      R                  D6$ )N)	requester )r   get_installation_authr+   githubGithubwithAuthkwargs)r,   installation_idr   s      r/   get_github_for_installation-GithubIntegration.get_github_for_installationx   sO    yy..'7'7 / 
 }}Ft//88>EEFFr2   c                 &    S[         R                  0$ )z.
Get headers for the requests.

:return: dict
Accept)r   mediaTypeIntegrationPreviewr,   s    r/   _get_headersGithubIntegration._get_headers   s     f88
 	
r2   c                     U R                   R                  SXR                  5       S9u  p#[        U R                   UUSS9$ )zh
Get installation for the given URL.

:param url: str
:rtype: :class:`github.Installation.Installation`
GETheadersTr4   rG   
attributes	completed)r+   requestJsonAndCheckrB   r   )r,   urlrG   responses       r/   _get_installed_app$GithubIntegration._get_installed_app   sR     !,,@@3 1 1 3 A 
 &&	
 	
r2   z|Use github.Github(auth=github.Auth.AppAuth), github.Auth.AppAuth.token or github.Auth.AppAuth.create_jwt(expiration) insteadc                 8    U R                   R                  U5      $ )z
Create a signed JWT
https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app

:return string:
)r   
create_jwt)r,   
expirations     r/   rQ   GithubIntegration.create_jwt   s     yy##J//r2   c                     Uc  0 n[        U[        5      (       d  [        SSS0SS9eSU0nU R                  R	                  SSU S	3U R                  5       US
9u  pE[        U R                  UUSS9$ )a   
:calls: `POST /app/installations/{installation_id}/access_tokens <https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app>`
:param installation_id: int
:param permissions: dict
:return: :class:`github.InstallationAuthorization.InstallationAuthorization`
Ni  messagezInvalid permissions)statusdatarG   permissionsPOST/app/installations/z/access_tokens)rG   inputTrH   )r   dictr   r+   rK   rB   r   )r,   r;   rX   bodyrG   rM   s         r/   get_access_token"GithubIntegration.get_access_token   s     K+t,,!)-B!CT  {+ ,,@@!/!2.A%%'	 A 
 )&&	
 	
r2   zUse get_repo_installationc                 .    U R                  SU SU S3S9$ )a  
Deprecated by get_repo_installation

:calls: `GET /repos/{owner}/{repo}/installation <https://docs.github.com/en/rest/reference/apps#get-a-repository-installation-for-the-authenticated-app>`
:param owner: str
:param repo: str
:rtype: :class:`github.Installation.Installation`
/repos///installationrL   rN   r,   ownerrepos      r/   get_installation"GithubIntegration.get_installation   s'     &&WUG1TF-+P&QQr2   c           	      V    [        [        U R                  SSU R                  5       SS9$ )z
:calls: GET /app/installations <https://docs.github.com/en/rest/reference/apps#list-installations-for-the-authenticated-app>
:rtype: :class:`github.PaginatedList.PaginatedList[github.Installation.Installation]`
z/app/installationsNinstallations)contentClassr4   firstUrlfirstParamsrG   	list_item)r	   r   r+   rB   rA   s    r/   get_installations#GithubIntegration.get_installations   s2    
 %&&)%%'%
 	
r2   c                 (    U R                  SU S3S9$ )z
:calls: `GET /orgs/{org}/installation <https://docs.github.com/en/rest/apps/apps#get-an-organization-installation-for-the-authenticated-app>`
:param org: str
:rtype: :class:`github.Installation.Installation`
z/orgs/rc   rd   re   )r,   orgs     r/   get_org_installation&GithubIntegration.get_org_installation   s!     &&VC5+F&GGr2   c                 .    U R                  SU SU S3S9$ )z
:calls: `GET /repos/{owner}/{repo}/installation <https://docs.github.com/en/rest/reference/apps#get-a-repository-installation-for-the-authenticated-app>`
:param owner: str
:param repo: str
:rtype: :class:`github.Installation.Installation`
ra   rb   rc   rd   re   rf   s      r/   get_repo_installation'GithubIntegration.get_repo_installation   s'     &&WUG1TF-+P&QQr2   c                 (    U R                  SU S3S9$ )z
:calls: `GET /users/{username}/installation <https://docs.github.com/en/rest/apps/apps#get-a-user-installation-for-the-authenticated-app>`
:param username: str
:rtype: :class:`github.Installation.Installation`
z/users/rc   rd   re   )r,   usernames     r/   get_user_installation'GithubIntegration.get_user_installation   s!     &&WXJm+L&MMr2   c                 &    U R                  SU 3S9$ )z
:calls: `GET /app/installations/{installation_id} <https://docs.github.com/en/rest/apps/apps#get-an-installation-for-the-authenticated-app>`
:param installation_id: int
:rtype: :class:`github.Installation.Installation`
rZ   rd   re   )r,   r;   s     r/   get_app_installation&GithubIntegration.get_app_installation   s!     &&-@@Q+R&SSr2   c                     U R                   R                  SSU R                  5       S9u  p[        U R                   XSS9$ )z
:calls: `GET /app <https://docs.github.com/en/rest/reference/apps#get-the-authenticated-app>`_
:rtype: :class:`github.GithubApp.GithubApp`
rE   z/apprF   TrH   )r+   rK   rB   r   )r,   rG   rW   s      r/   get_appGithubIntegration.get_app   sN     ((<<64#4#4#6 = 
 &&TX
 	
r2   )__requesterr   r   )N)__name__
__module____qualname____firstlineno____doc__r   DEFAULT_BASE_URLDEFAULT_TIMEOUTDEFAULT_USER_AGENTDEFAULT_PER_PAGEr$   r%   r&   r0   r<   rB   rN   
deprecatedrQ   r^   ri   rq   ru   rx   r|   r   r   __static_attributes__r5   r2   r/   r   r      s     ((	Z
 &&,,((,,2222Z
xG

$  	G00
< 67	R 8	R
HRNT
r2   r   )r'   r   r   r7   r   github.Authr   github.GithubAppr   github.GithubExceptionr   github.Installationr    github.InstallationAuthorizationr   github.PaginatedListr	   github.Requesterr
   r   r5   r2   r/   <module>r      s5          & 2 , F . &z
 z
r2   