
    i7                     :   d dl Zd dlmZ ddlmZ ddlmZmZ ddl	m
Z
mZ ddlT ddlmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= dd l>m?Z? dd!l@mAZA dd"lBmCZC dd#lDmEZE dd$lFmGZG dd%lHmIZI dd&lJmKZK dd'lLmMZM dd(lNmOZO dd)lPmQZQ dd*lRmSZS dd+lTmUZU dd,lVmWZW dd-lXmYZY dd.lZm[Z[ dd/l\m]Z] dd0l^m_Z_ dd1l`maZa dd2lbmcZc dd3ldmeZe dd4lfmgZg dd5lhmiZi dd6ljmkZk dd7llmmZm dd8lnmoZo dd9lpmqZq dd:lrmsZs dd;ltmuZu dd<lvmwZw dd=lxmyZy dd>lzm{Z{ dd?l|m}Z} d@e~dAdfdBZ G dC dDe          Z G dE dFe          ZdS )G    N)Optional   )Files)UTF_8APPLICATION_JSON)loggerJSON)*)TokenManagerverify)	Transport)BoardService)CardkitService)DocxService)	VcService)AuthService)CompensationService)HumanAuthenticationService)MinutesService)SpeechToTextService)EventService)OpticalCharRecognitionService)VerificationService)ApprovalService)DocumentAiService)
MdmService)
OkrService)SearchService)AdminService)ApplicationService)AuthenService)MailService)WikiService)CalendarService)CorehrService)ApaasService)DirectoryService)AilyService)SecurityAndComplianceService)SheetsService)BaikeService)BitableService)WorkplaceService)TenantService)TranslationService)
AcsService)AttendanceService)BlockService)	ImService)PersonalSettingsService)TaskService)BaseService)LingoService)MomentsService)ReportService)MeetingRoomService)ContactService)
EhrService)HireService)HelpdeskService)PassportService)PayrollService)DocsService)DriveService)PerformanceServicedomainreturnc                    t          | t                    r| st          d          t          j                            |           }|j        dk    r3|j        pd                                }|dvrt          d| d          n|j        dk    rt          d| d          |j	        st          d| d          d	|j	        v rt          d
| d          |j
        s|j        s|j        rt          d| d          dS )uM  Reject domains that could redirect API traffic (carrying app_secret /
    Authorization headers) to attacker-controlled hosts.

    Accepted form: ``https://host[:port]`` only — no path, query, fragment,
    or embedded credentials. http:// is allowed only for localhost loopback
    (common for in-process integration tests).
    z$domain must be a non-empty https URLhttp )z	127.0.0.1	localhostz::1z"domain must use https scheme (got )httpszdomain missing host (got @z'domain must not embed credentials (got zQdomain must be an origin (scheme + host[:port]) without path/query/fragment (got N)
isinstancestr
ValueErrorurllibparseurlsplitschemehostnamelowernetlocpathqueryfragment)rD   parsedhosts      W/home/piyush/.hermes/hermes-agent/venv/lib/python3.11/site-packages/lark_oapi/client.py_validate_domainr]   D   sM    fc"" A& A?@@@\""6**F}%2,,..888M&MMMNNN 9	'	!	!IfIIIJJJ= B@V@@@AAA
fmN6NNNOOO{ 
fl 
fo 
k`fkkk
 
 	

 
    c                       e Zd ZddZedd            Zedee         fd            Z	dde
dee         defd	Zdde
dee         defd
ZdS )ClientrE   Nc                    d | _         d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _	        d | _
        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _         d | _!        d | _"        d | _#        d | _$        d | _%        d | _&        d | _'        d | _(        d | _)        d | _*        d | _+        d | _,        d | _-        d | _.        d | _/        d | _0        d | _1        d | _2        d | _3        d | _4        d | _5        d | _6        d S N)7_configboardcardkitdocxvcauthcompensationhuman_authenticationminutesspeech_to_texteventoptical_char_recognitionverificationapprovaldocument_aimdmokrsearchadminapplicationauthenmailwikicalendarcorehrapaas	directoryailysecurity_and_compliancesheetsbaikebitable	workplacetenanttranslationacs
attendanceblockimpersonal_settingstaskbaselingomomentsreportmeeting_roomcontactehrhirehelpdeskpassportpayrolldocsdriveperformanceselfs    r\   __init__zClient.__init__`   s   )--1
15+/	'++/	;?JN!15=A-1
QU%;?378<)-)-/3-1
9=/3+/	+/	37/3-1
59+/	OS$/3-1
1559/39=)-7;-1
'+DH+/	+/	-1
15/3:>15)-+/	373715+/	-1
9=r^   ClientBuilderc                      t                      S rb   )r    r^   r\   builderzClient.builder   s    r^   c                     | j         S )ur  Read-only view of the client's ``Config`` (app_id, app_secret, domain, …).

        Exposed so companion modules (e.g. ``lark_oapi.channel``) can read
        credentials/domain without reaching into the private ``_config``
        attribute. Returns ``None`` if the client was constructed without a
        config (e.g. default ``Client()`` with no builder).
        )rc   r   s    r\   configzClient.config   s     |r^   requestoptionc                    |t                      }t          | j        ||           t          j        | j        ||          }t                      }|j                            t                    }|M|	                    t                    r3t          j        t          |j        t                    t
                    }nd|j        cxk    rdk     r
n nd|_        ||_        |S N   i,  r   )RequestOptionr   rc   r   executeBaseResponseheadersgetCONTENT_TYPE
startswithr   r	   	unmarshalrN   contentr   status_codecoderawr   r   r   raw_resprespcontent_types         r\   r   zClient.request   s    >"__F 	t|Wf--- $T\7FCC ~~'++L99#(?(?@P(Q(Q#>#h&6">">MMDDH(....3.....DIr^   c                   K   |t                      }t          | j        ||           t          j        |j                  |_        t          j        | j        ||           d {V }t                      }|j
                            t                    }|M|                    t                    r3t          j        t#          |j        t&                    t                    }nd|j        cxk    rdk     r
n nd|_        ||_        |S r   )r   r   rc   r   extract_filesbodyfilesr   aexecuter   r   r   r   r   r   r	   r   rN   r   r   r   r   r   r   s         r\   arequestzClient.arequest   s      >"__F 	t|Wf--- +GL99 #+DL'6JJJJJJJJ ~~'++L99#(?(?@P(Q(Q#>#h&6">">MMDDH(....3.....DIr^   rE   N)rE   r   rb   )__name__
__module____qualname__r   staticmethodr   propertyr   Configr   BaseRequestr   r   r   r   r   r^   r\   r`   r`   _   s        7> 7> 7> 7>r    \ (    X { H]4K Wc    * k 8M;R ^j      r^   r`   c                       e Zd ZddZdedd fdZdedd fdZdedd fd	Zd
edd fdZ	de
dd fdZdedd fdZdedd fdZdedd fdZdedd fdZdedd fdZdefdZd Zd ZdS )r   rE   Nc                 ,    t                      | _        d S rb   )r   rc   r   s    r\   r   zClientBuilder.__init__   s    xxr^   app_idc                     || j         _        | S rb   )rc   r   )r   r   s     r\   r   zClientBuilder.app_id   s    $r^   
app_secretc                     || j         _        | S rb   )rc   r   )r   r   s     r\   r   zClientBuilder.app_secret       ",r^   rD   c                 <    t          |           || j        _        | S rb   )r]   rc   rD   )r   rD   s     r\   rD   zClientBuilder.domain   s       $r^   timeoutc                     || j         _        | S rb   )rc   r   )r   r   s     r\   r   zClientBuilder.timeout   s    &r^   app_typec                     || j         _        | S rb   )rc   r   )r   r   s     r\   r   zClientBuilder.app_type   s     (r^   
app_ticketc                     || j         _        | S rb   )rc   r   )r   r   s     r\   r   zClientBuilder.app_ticket   r   r^   enable_set_tokenc                     || j         _        | S rb   )rc   r   )r   r   s     r\   r   zClientBuilder.enable_set_token   s    (8%r^   cachec                     || j         _        | S rb   )rc   r   )r   r   s     r\   r   zClientBuilder.cache   s    "r^   	log_levelc                     || j         _        | S rb   )rc   r   )r   r   s     r\   r   zClientBuilder.log_level   s    !*r^   sourcec                     || j         _        | S )z<Caller tag appended to User-Agent as ``source/<sanitized>``.)rc   r   )r   r   s     r\   r   zClientBuilder.source   s    $r^   c                    t                      }| j        |_        |                                  |                                  t	          | j                  |_        t          | j                  |_        t          | j                  |_	        t          | j                  |_        t          | j                  |_        t          | j                  |_        t!          | j                  |_        t%          | j                  |_        t)          | j                  |_        t-          | j                  |_        t1          | j                  |_        t5          | j                  |_        t9          | j                  |_        t=          | j                  |_        tA          | j                  |_!        tE          | j                  |_#        tI          | j                  |_%        tM          | j                  |_'        tQ          | j                  |_)        tU          | j                  |_+        tY          | j                  |_-        t]          | j                  |_/        ta          | j                  |_1        te          | j                  |_3        ti          | j                  |_5        tm          | j                  |_7        tq          | j                  |_9        tu          | j                  |_;        ty          | j                  |_=        t}          | j                  |_?        t          | j                  |_A        t          | j                  |_C        t          | j                  |_E        t          | j                  |_G        t          | j                  |_I        t          | j                  |_K        t          | j                  |_M        t          | j                  |_O        t          | j                  |_Q        t          | j                  |_S        t          | j                  |_U        t          | j                  |_W        t          | j                  |_Y        t          | j                  |_[        t          | j                  |_]        t          | j                  |__        t          | j                  |_a        t          | j                  |_c        t          | j                  |_e        t          | j                  |_g        t          | j                  |_i        t          | j                  |_k        t          | j                  |_m        t          | j                  |_o        |S rb   )pr`   rc   _init_cache_init_loggerr   rd   r   re   r   rf   r   rg   r   rh   r   ri   r   rj   r   rk   r   rl   r   rm   r   rn   r   ro   r   rp   r   rq   r   rr   r   rs   r   rt   r   ru   r    rv   r!   rw   r"   rx   r#   ry   r$   rz   r%   r{   r&   r|   r'   r}   r(   r~   r)   r   r*   r   r+   r   r,   r   r-   r   r.   r   r/   r   r0   r   r1   r   r2   r   r3   r   r4   r   r5   r   r6   r   r7   r   r8   r   r9   r   r:   r   r;   r   r<   r   r=   r   r>   r   r?   r   r@   r   rA   r   rB   r   rC   r   )r   clients     r\   buildzClientBuilder.build  s    	 	 $DL11'55!$,//dl++	!$,//1$,??&@&N&N#'55 3DL A A#DL11*G*U*U'1$,??)$,77.t|<<--
--
%dl33#DL11/==%dl33!$,//!$,//)$,77%dl33#DL11+DL99!$,//)Edl)S)S&%dl33#DL11'55+DL99%dl33/==--
-dl;;#DL11dl++	#:4<#H#H !$,//!$,//#DL11'55%dl330>>'55--
!$,//)$,77)$,77'55!$,//#DL11/==r^   c                 N    | j         j        | j         j        t          _        d S d S rb   )rc   r   r   r   s    r\   r   zClientBuilder._init_cacheH  s(    <)!%!3L *)r^   c                 f    t          j        t          | j        j        j                             d S rb   )r   setLevelintrc   r   valuer   s    r\   r   zClientBuilder._init_loggerL  s(    DL2899:::::r^   r   )r   r   r   r   rN   r   r   rD   floatr   AppTyper   r   boolr   ICacher   LogLevelr   r   r`   r   r   r   r   r^   r\   r   r      s              S _    S _    S _    
u      _    S _     /    6 o    8     S _    
Bv B B B BH4 4 4; ; ; ; ;r^   r   )urllib.parserP   typingr   core.utils.filesr   
core.constr   r   corer   r	   
core.model
core.tokenr   r   	core.httpr   api.board.servicer   api.cardkit.servicer   api.docx.servicer   api.vc.servicer   api.auth.servicer   api.compensation.servicer    api.human_authentication.servicer   api.minutes.servicer   api.speech_to_text.servicer   api.event.servicer   $api.optical_char_recognition.servicer   api.verification.servicer   api.approval.servicer   api.document_ai.servicer   api.mdm.servicer   api.okr.servicer   api.search.servicer   api.admin.servicer   api.application.servicer    api.authen.servicer!   api.mail.servicer"   api.wiki.servicer#   api.calendar.servicer$   api.corehr.servicer%   api.apaas.servicer&   api.directory.servicer'   api.aily.servicer(   #api.security_and_compliance.servicer)   api.sheets.servicer*   api.baike.servicer+   api.bitable.servicer,   api.workplace.servicer-   api.tenant.servicer.   api.translation.servicer/   api.acs.servicer0   api.attendance.servicer1   api.block.servicer2   api.im.servicer3   api.personal_settings.servicer4   api.task.servicer5   api.base.servicer6   api.lingo.servicer7   api.moments.servicer8   api.report.servicer9   api.meeting_room.servicer:   api.contact.servicer;   api.ehr.servicer<   api.hire.servicer=   api.helpdesk.servicer>   api.passport.servicer?   api.payroll.servicer@   api.docs.servicerA   api.drive.servicerB   api.performance.servicerC   rN   r]   objectr`   r   r   r^   r\   <module>r*     s             # # # # # # / / / / / / / /             , , , , , , , ,             + + + + + + / / / / / / ) ) ) ) ) ) % % % % % % ) ) ) ) ) ) 9 9 9 9 9 9 H H H H H H / / / / / / ; ; ; ; ; ; + + + + + + O O O O O O 9 9 9 9 9 9 1 1 1 1 1 1 6 6 6 6 6 6 ' ' ' ' ' ' ' ' ' ' ' ' - - - - - - + + + + + + 7 7 7 7 7 7 - - - - - - ) ) ) ) ) ) ) ) ) ) ) ) 1 1 1 1 1 1 - - - - - - + + + + + + 3 3 3 3 3 3 ) ) ) ) ) ) M M M M M M - - - - - - + + + + + + / / / / / / 3 3 3 3 3 3 - - - - - - 7 7 7 7 7 7 ' ' ' ' ' ' 5 5 5 5 5 5 + + + + + + % % % % % % B B B B B B ) ) ) ) ) ) ) ) ) ) ) ) + + + + + + / / / / / / - - - - - - 8 8 8 8 8 8 / / / / / / ' ' ' ' ' ' ) ) ) ) ) ) 1 1 1 1 1 1 1 1 1 1 1 1 / / / / / / ) ) ) ) ) ) + + + + + + 7 7 7 7 7 7
S 
T 
 
 
 
6t t t t tV t t tnw; w; w; w; w;F w; w; w; w; w;r^   