
    m>h^                     &    d dl mZ  G d de      Zy)    )Jwtc                        e Zd ZdZdZdZdZ fdZed        Z	ed        Z
ed        Zd	 Zd
 Zd Zd Zd Zd ZddZd ZddZd Zd Z xZS )TaskRouterCapabilityTokenv1zhttps://taskrouter.twilio.comz-https://event-bridge.twilio.com/v1/wschannelsHS256c                    t         t        |   ||| j                  |j	                  dt
        j                        |j	                  dd      |j	                  dd             | j                  |||       || _        || _	        || _
        || _        g | _        |j	                  dd      r| j                          |j	                  d	d      r| j                          |j	                  d
d      r| j                          |j	                  dd      r| j!                          |j	                  dd      r| j#                          |j	                  dd      r| j%                          |j	                  dd      r| j'                          yy)a  
        :param str account_sid: Twilio account sid
        :param str auth_token: Twilio auth token used to sign the JWT
        :param str workspace_sid: TaskRouter workspace sid
        :param str channel_id: TaskRouter channel sid
        :param kwargs:
            :param bool allow_web_sockets: shortcut to calling allow_web_sockets, defaults to True
            :param bool allow_fetch_self: shortcut to calling allow_fetch_self, defaults to True
            :param bool allow_update_self: shortcut to calling allow_update_self, defaults to False
            :param bool allow_delete_self: shortcut to calling allow_delete_self, defaults to False
            :param bool allow_fetch_subresources: shortcut to calling allow_fetch_subresources,
                                                  defaults to False
            :param bool allow_update_subresources: shortcut to calling allow_update_subresources,
                                                   defaults to False
            :param bool allow_delete_subresources: shortcut to calling allow_delete_subresources,
                                                   defaults to False
        :returns a new TaskRouterCapabilityToken with capabilities set depending on kwargs.
        nbfttli  valid_untilN)
secret_keyissuer	algorithmr	   r
   r   allow_web_socketsTallow_fetch_selfallow_update_selfFallow_delete_selfallow_fetch_subresourcesallow_delete_subresourcesallow_update_subresources)superr   __init__	ALGORITHMgetr   GENERATE_validate_inputsaccount_sid
auth_tokenworkspace_sid
channel_idpoliciesr   r   r   r   r   r   r   )selfr   r   r   r   kwargs	__class__s         b/var/www/html/DP/alpha_backend/venv/lib/python3.12/site-packages/twilio/jwt/taskrouter/__init__.pyr   z"TaskRouterCapabilityToken.__init__
   sP   & 	'7!nn

5#,,/

5$'

=$7 	8 	
 	k=*E&$*$::)40""$::($/!!#::)51""$::)51""$::0%8))+::159**,::159**, :    c                 d    dj                  | j                  | j                  | j                        S )Nz{}/{}/Workspaces/{})formatDOMAINVERSIONr   r!   s    r$   workspace_urlz'TaskRouterCapabilityToken.workspace_url=   s*    $++KKt'9'9
 	
r%   c                     t        d      )Nz,Subclass must set its specific resource_url.NotImplementedErrorr*   s    r$   resource_urlz&TaskRouterCapabilityToken.resource_urlC   s    !"PQQr%   c                     t        d      )Nz5Subclass must set its specific channel_id sid prefix.r-   r*   s    r$   channel_prefixz(TaskRouterCapabilityToken.channel_prefixG   s    !C
 	
r%   c                 >    | j                  | j                  dd       y )NGETT_make_policyr/   r*   s    r$   r   z*TaskRouterCapabilityToken.allow_fetch_selfM   s    $++UD9r%   c                 >    | j                  | j                  dd       y )NPOSTTr4   r*   s    r$   r   z+TaskRouterCapabilityToken.allow_update_selfP   s    $++VT:r%   c                 >    | j                  | j                  dd       y )NDELETETr4   r*   s    r$   r   z+TaskRouterCapabilityToken.allow_delete_selfS   s    $++Xt<r%   c                 D    | j                  | j                  dz   dd       y )N/**r3   Tr4   r*   s    r$   r   z2TaskRouterCapabilityToken.allow_fetch_subresourcesV   s    $++e3UDAr%   c                 D    | j                  | j                  dz   dd       y )Nr;   r7   Tr4   r*   s    r$   r   z3TaskRouterCapabilityToken.allow_update_subresourcesY   s    $++e3VTBr%   c                 D    | j                  | j                  dz   dd       y )Nr;   r9   Tr4   r*   s    r$   r   z3TaskRouterCapabilityToken.allow_delete_subresources\   s    $++e3XtDr%   c                     |xs | j                   }dj                  | j                  | j                  |      }| j	                  |dd       | j	                  |dd       y )Nz{}/{}/{}r3   Tr7   )r   r'   EVENTS_BASE_URLr   r5   )r!   r   web_socket_urls      r$   r   z+TaskRouterCapabilityToken.allow_web_sockets_   sY    24??
#**  $"2"2J
 	.%6.&$7r%   c                 <   | j                   | j                  | j                  | j                  | j                  | j                  d}| j                  j                  d      r| j                  |d<   |S | j                  j                  d      r| j                  |d<   |S )N)r   r   channelversionfriendly_namer    WK
worker_sidWQtaskqueue_sid)r   r   r   r)   r    
startswith)r!   payloads     r$   _generate_payloadz+TaskRouterCapabilityToken._generate_payloadg   s    ++!//||!__
 ??%%d+$(OOGL!  __''-'+GO$r%   c                 r    | j                   j                  ||j                         ||xs i |xs i d       y )N)urlmethodallowquery_filterpost_filter)r    appendupper)r!   rM   rN   allowedrP   rQ   s         r$   r5   z&TaskRouterCapabilityToken._make_policyx   s8     ,,.  , 2*0b	
r%   c                 &   |r|j                  d      st        dj                  |            |r|j                  d      st        dj                  |            |r|j                  | j                        st        dj                  |            y )NACzInvalid account sid provided {}WSz!Invalid workspace sid provided {}zInvalid channel id provided {})rI   
ValueErrorr'   r1   )r!   r   r   r   s       r$   r   z*TaskRouterCapabilityToken._validate_inputs   s    +"8"8">>EEkRSSM$<$<T$B@GGVWW!6!6t7J7J!K=DDZPQQ "Lr%   c                 @    dj                  | j                               S )Nz<TaskRouterCapabilityToken {}>)r'   to_jwtr*   s    r$   __str__z!TaskRouterCapabilityToken.__str__   s    /66t{{}EEr%   )N)NN)__name__
__module____qualname__r)   r(   r?   r   r   propertyr+   r/   r1   r   r   r   r   r   r   r   rK   r5   r   r[   __classcell__)r#   s   @r$   r   r      s    G,FEOI1-f 
 

 R R 
 

:;=BCE8"	
RFr%   r   N)
twilio.jwtr   r    r%   r$   <module>rc      s    JF JFr%   