ó
    Ð]j  ã                  óÂ   • S SK Jr  S SKJr  S SKJr  S SKJrJr  S SK	J
r
  S SKJr  S SKJr  SS	KJrJr  SS
KJr  S\ 3r " S S\5      r " S S\5      r " S S5      rg)é    )Úannotations)ÚAny)Úurljoin)ÚResponseÚSession)ÚSelf)ÚLogfireConfigError)ÚVERSIONé   )Ú	UserTokenÚUserTokenCollection)ÚUnexpectedResponsezlogfire/c                  ó   • \ rS rSrSrg)ÚProjectAlreadyExistsé   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    ÚU/home/mande/repo/quber/.venv/lib/python3.13/site-packages/logfire/_internal/client.pyr   r      s   † Úr   r   c                  ó   • \ rS rSrSS jrSrg)ÚInvalidProjectNameé   c               ó   • Xl         g ©N©Úreason)Úselfr    s     r   Ú__init__ÚInvalidProjectName.__init__   s   € Ø�r   r   N)r    ÚstrÚreturnÚNone)r   r   r   r   r"   r   r   r   r   r   r      s   † ÷r   r   c                  óÜ   • \ rS rSrSrSS jr\SS j5       rSSS jjrSS.SS jjr	SSS	 jjr
SSS
 jjrSS.SS jjrSS.SS jjrSS jrSS jrSS jrSS jrS S jrS S jrS!S jrSrg)"ÚLogfireClienté   z‚A Logfire HTTP client to interact with the API.

Args:
    user_token: The user token to use when authenticating against the API.
c                ó
  • UR                   (       a  [        S5      eUR                  U l        UR                  U l        [        5       U l        U R                  R                  R                  U R                  [        S.5        g )Nz"The provided user token is expired)ÚAuthorizationz
User-Agent)
Ú
is_expiredÚRuntimeErrorÚbase_urlÚtokenÚ_tokenr   Ú_sessionÚheadersÚupdateÚ	UA_HEADER)r!   Ú
user_tokens     r   r"   ÚLogfireClient.__init__"   s\   € Ø× × ÜÐCÓDÐDØ"×+Ñ+ˆŒØ ×&Ñ&ˆŒÜ›	ˆŒØ�‰×Ñ×$Ñ$°t·{±{ÔR[Ñ%\Õ]r   c                ó<   • U " [        5       R                  U5      S9$ )a‚  Create a client from the provided base URL.

Args:
    base_url: The base URL to use when looking for a user token. If `None`, will prompt
        the user into selecting a token from the token collection (or, if only one available,
        use it directly). The token collection will be created from the `~/.logfire/default.toml`
        file (or an empty one if no such file exists).
)r5   )r   Ú	get_token)Úclsr.   s     r   Úfrom_urlÚLogfireClient.from_url*   s   € ñ Ô1Ó3×=Ñ=¸hÓGÑHÐHr   Nc                óŽ   • U R                   R                  [        U R                  U5      US9n[        R
                  " U5        U$ )N©Úparams)r1   Úgetr   r.   r   Úraise_for_status)r!   Úendpointr>   Úresponses       r   Ú_get_rawÚLogfireClient._get_raw6   s9   € Ø—=‘=×$Ñ$¤W¨T¯]©]¸HÓ%EÈfÐ$ÐUˆÜ×+Ò+¨HÔ5Øˆr   r=   c               ó~   •  U R                  X5      R                  5       $ ! [         a  n[        U5      UeS nAff = fr   )rC   Újsonr   r	   )r!   rA   r>   Úerror_messageÚes        r   Ú_getÚLogfireClient._get;   s<   € ð	;Ø—=‘= Ó2×7Ñ7Ó9Ð9øÜ!ó 	;Ü$ ]Ó3¸Ð:ûð	;úó   ‚! ¡
<«7·<c                óŽ   • U R                   R                  [        U R                  U5      US9n[        R
                  " U5        U$ ©N)rF   )r1   Úpostr   r.   r   r@   ©r!   rA   ÚbodyrB   s       r   Ú	_post_rawÚLogfireClient._post_rawA   s9   € Ø—=‘=×%Ñ%¤g¨d¯m©m¸XÓ&FÈTÐ%ÐRˆÜ×+Ò+¨HÔ5Øˆr   c                óŽ   • U R                   R                  [        U R                  U5      US9n[        R
                  " U5        U$ rM   )r1   Úputr   r.   r   r@   rO   s       r   Ú_put_rawÚLogfireClient._put_rawF   s9   € Ø—=‘=×$Ñ$¤W¨T¯]©]¸HÓ%EÈDÐ$ÐQˆÜ×+Ò+¨HÔ5Øˆr   ©rP   c               ó~   •  U R                  X5      R                  5       $ ! [         a  n[        U5      UeS nAff = fr   )rU   rF   r   r	   ©r!   rA   rP   rG   rH   s        r   Ú_putÚLogfireClient._putK   s<   € ð	;Ø—=‘= Ó0×5Ñ5Ó7Ð7øÜ!ó 	;Ü$ ]Ó3¸Ð:ûð	;úrK   c               ó~   •  U R                  X5      R                  5       $ ! [         a  n[        U5      UeS nAff = fr   )rQ   rF   r   r	   rY   s        r   Ú_postÚLogfireClient._postQ   s<   € ð	;Ø—>‘> (Ó1×6Ñ6Ó8Ð8øÜ!ó 	;Ü$ ]Ó3¸Ð:ûð	;úrK   c                ó"   • U R                  SSS9$ )z,Get the organizations of the logged-in user.z)/v1/organizations/available-for-projects/z&Error retrieving list of organizations©rG   ©rI   ©r!   s    r   Úget_user_organizationsÚ$LogfireClient.get_user_organizationsW   s   € à�y‰yØ7ÐGoð ð 
ð 	
r   c                ó"   • U R                  SSS9$ )z)Get information about the logged-in user.z/v1/account/mez!Error retrieving user informationr`   ra   rb   s    r   Úget_user_informationÚ"LogfireClient.get_user_information]   s   € à�y‰yÐ)Ð9\ˆyÐ]Ð]r   c                ó"   • U R                  SSS9$ )z'Get the projects of the logged-in user.z/v1/writable-projects/z!Error retrieving list of projectsr`   ra   rb   s    r   Úget_user_projectsÚLogfireClient.get_user_projectsa   s   € à�y‰yÐ1ÐAdˆyÐeÐer   c                óL  •  U R                  SU S3SU0S9nUR                  5       $ ! [         aq  nUR                  nUR                  S:X  a  [        eUR                  S:X  a/  UR                  5       S   S   nUS	   S
S/:X  a  [        US   5      e[        S5      eSnAff = f)zÄCreate a new project.

Args:
    organization: The organization that should hold the new project.
    project_name: The name of the project to be created.

Returns:
    The newly created project.
ú/v1/organizations/z	/projectsÚproject_namerW   i™  i¦  Údetailr   ÚlocrP   ÚmsgzError creating new projectN)rQ   r   rB   Ústatus_coder   rF   r   r	   )r!   Úorganizationrm   rB   rH   ÚrÚerrors          r   Úcreate_new_projectÚ LogfireClient.create_new_projecte   sµ   € ð	CØ—~‘~Ð(:¸<¸.È	Ð&RÐZhÐjvÐYw�~ÐxˆHð �}‰}‹Ðøô "ó 		CØ—
‘
ˆAØ�}‰} Ó#Ü*Ð*Ø�}‰} Ó#ØŸ™› Ñ*¨1Ñ-�Ø˜‘< F¨NÐ#;Ó;Ü,¨U°5©\Ó:Ð:ä$Ð%AÓBÐBûð		Cús   ‚( ¨
B#²A,BÂB#c                ó0   • U R                  SU SU S3SS9$ )zECreate a write token for the given project in the given organization.rl   ú
/projects/z/write-tokens/z"Error creating project write tokenr`   ©r]   ©r!   rr   rm   s      r   Úcreate_write_tokenÚ LogfireClient.create_write_token}   s-   € à�z‰zØ   ¨j¸¸ÀnÐUØ>ð ð 
ð 	
r   c                ó6   • U R                  SU SU S3SS0SS9$ )zDCreate a read token for the given project in the given organization.rl   rx   z/read-tokensÚdescriptionzCreated by Logfire CLIz!Error creating project read token)rP   rG   ry   rz   s      r   Úcreate_read_tokenÚLogfireClient.create_read_token„   s6   € à�z‰zØ   ¨j¸¸ÀlÐSØÐ!9Ð:Ø=ð ð 
ð 	
r   c                ó6   • U R                  SU SU S3SU0SS9$ )z/Get a prompt to be used with your favorite LLM.rl   rx   z/promptsÚissuezError retrieving prompt)r>   rG   ra   )r!   rr   rm   r‚   s       r   Ú
get_promptÚLogfireClient.get_promptŒ   s5   € à�y‰yØ   ¨j¸¸ÀhÐOØ˜UÐ#Ø3ð ð 
ð 	
r   )r1   r0   r.   )r5   r   r%   r&   )r.   z
str | Noner%   r   r   )rA   r$   r>   údict[str, Any] | Noner%   r   )rA   r$   r>   r…   rG   r$   r%   r   )rA   r$   rP   ú
Any | Noner%   r   )rA   r$   rP   r†   rG   r$   r%   r   )r%   zlist[dict[str, Any]])r%   údict[str, Any])rr   r$   rm   r$   )rr   r$   rm   r$   r%   r‡   )rr   r$   rm   r$   r‚   r$   r%   r‡   )r   r   r   r   Ú__doc__r"   Úclassmethodr:   rC   rI   rQ   rU   rZ   r]   rc   rf   ri   ru   r{   r   rƒ   r   r   r   r   r(   r(      sw   † ñô^ð ó	Ió ð	Iöð
 FJ÷ ;öö
ð
 9=÷ ;ð :>÷ ;ô
ô^ôfôô0
ô
÷
r   r(   N)Ú
__future__r   Útypingr   Úurllib.parser   Úrequestsr   r   Útyping_extensionsr   Úlogfire.exceptionsr	   Úlogfire.versionr
   Úauthr   r   Úutilsr   r4   Ú	Exceptionr   r   r(   r   r   r   Ú<module>r”      sP   ðÝ "å Ý  ç &Ý "å 1Ý #ç 0Ý %à�w�iÐ €	ô	˜9ô 	ô˜ô ÷
w
ò w
r   