U
    ^g%iZN                     @   s   d Z ddlmZ ddlmZmZmZmZmZmZm	Z	 ddl
mZ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 G d
d deZG dd deZG dd deZG dd deZdS )a  
    This code was generated by
   ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
    |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
    |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \

    Twilio - Ip_messaging
    This is the public Twilio REST API.

    NOTE: This class is auto generated by OpenAPI Generator.
    https://openapi-generator.tech
    Do not edit the class manually.
    )datetime)AnyDictListOptionalUnionIteratorAsyncIterator)deserialize	serializevalues)InstanceContext)InstanceResource)ListResource)Version)Pagec                       s   e Zd ZG dd deZdeeeef ee	e d fddZ
eddd	d
ZedddZedddZd dddZd dddZee d dddZee d dddZedddZ  ZS )RoleInstancec                   @   s   e Zd ZdZdZdS )RoleInstance.RoleTypeZchannelZ
deploymentN)__name__
__module____qualname__ZCHANNELZ
DEPLOYMENT r   r   g/var/www/html/api-medvista/venv/lib/python3.8/site-packages/twilio/rest/ip_messaging/v2/service/role.pyRoleType   s   r   N)versionpayloadservice_sidsidc                    s   t  | |d| _|d| _|d| _|d| _|d| _|d| _t	
|d| _t	
|d| _|d	| _||p| jd
| _d | _d S )Nr   account_sidr   friendly_nametypepermissionsdate_createddate_updatedurlr   r   )super__init__getr   r   r   r   r    r!   r
   Ziso8601_datetimer"   r#   r$   	_solution_context)selfr   r   r   r   	__class__r   r   r'   +   s$    zRoleInstance.__init__RoleContextreturnc                 C   s.   | j dkr(t| j| jd | jd d| _ | j S )z
        Generate an instance context for the instance, the context is capable of
        performing various actions. All instance actions are proxied to the context

        :returns: RoleContext for this RoleInstance
        Nr   r   r%   )r*   r.   _versionr)   r+   r   r   r   _proxyH   s    
zRoleInstance._proxyc                 C   s
   | j  S )g
        Deletes the RoleInstance


        :returns: True if delete succeeds, False otherwise
        )r3   deleter2   r   r   r   r5   X   s    zRoleInstance.deletec                    s   | j  I dH S )
        Asynchronous coroutine that deletes the RoleInstance


        :returns: True if delete succeeds, False otherwise
        N)r3   delete_asyncr2   r   r   r   r7   a   s    zRoleInstance.delete_asyncc                 C   s
   | j  S )U
        Fetch the RoleInstance


        :returns: The fetched RoleInstance
        )r3   fetchr2   r   r   r   r9   j   s    zRoleInstance.fetchc                    s   | j  I dH S )o
        Asynchronous coroutine to fetch the RoleInstance


        :returns: The fetched RoleInstance
        N)r3   fetch_asyncr2   r   r   r   r;   s   s    zRoleInstance.fetch_async
permissionr0   c                 C   s   | j j|dS )q
        Update the RoleInstance

        :param permission:

        :returns: The updated RoleInstance
        r=   )r3   updater+   r=   r   r   r   r@   |   s    zRoleInstance.updatec                    s   | j j|dI dH S )
        Asynchronous coroutine to update the RoleInstance

        :param permission:

        :returns: The updated RoleInstance
        r?   N)r3   update_asyncrA   r   r   r   rC      s    zRoleInstance.update_asyncc                 C   s$   d dd | j D }d|S )f
        Provide a friendly representation

        :returns: Machine friendly representation
         c                 s   s   | ]\}}d  ||V  qdS z{}={}Nformat.0kvr   r   r   	<genexpr>   s     z(RoleInstance.__repr__.<locals>.<genexpr>z'<Twilio.IpMessaging.V2.RoleInstance {}>joinr)   itemsrH   r+   contextr   r   r   __repr__   s    zRoleInstance.__repr__)N)r   r   r   objectr   r   r   strr   r   r'   propertyr3   boolr5   r7   r9   r;   r   r@   rC   rS   __classcell__r   r   r,   r   r      s"    
				r   c                       s   e Zd Zeeed fddZedddZedddZe	dd	d
Z
e	dddZee e	dddZee e	dddZedddZ  ZS )r.   )r   r   r   c                    s,   t  | ||d| _djf | j| _dS )z
        Initialize the RoleContext

        :param version: Version that contains the resource
        :param service_sid:
        :param sid:
        r%   z#/Services/{service_sid}/Roles/{sid}Nr&   r'   r)   rH   _uri)r+   r   r   r   r,   r   r   r'      s
    zRoleContext.__init__r/   c                 C   s   t i }| jjd| j|dS )r4   DELETEmethoduriheaders)r   ofr1   r5   rZ   r+   r_   r   r   r   r5      s    
zRoleContext.deletec                    s$   t i }| jjd| j|dI dH S )r6   r[   r\   N)r   r`   r1   r7   rZ   ra   r   r   r   r7      s    
  zRoleContext.delete_asyncc                 C   sD   t i }d|d< | jjd| j|d}t| j|| jd | jd dS )r8   application/jsonAcceptGETr\   r   r   r%   )r   r`   r1   r9   rZ   r   r)   r+   r_   r   r   r   r   r9      s    
zRoleContext.fetchc                    sJ   t i }d|d< | jjd| j|dI dH }t| j|| jd | jd dS )	r:   rb   rc   rd   r\   Nr   r   r%   )r   r`   r1   r;   rZ   r   r)   re   r   r   r   r;      s    
  zRoleContext.fetch_asyncr<   c                 C   sh   t dt|dd i}t i }d|d< d|d< | jjd| j||d	}t| j|| jd
 | jd dS )r>   
Permissionc                 S   s   | S Nr   er   r   r   <lambda>      z$RoleContext.update.<locals>.<lambda>!application/x-www-form-urlencodedContent-Typerb   rc   POSTr]   r^   datar_   r   r   r%   )	r   r`   r   mapr1   r@   rZ   r   r)   r+   r=   rp   r_   r   r   r   r   r@      s(    	 
   zRoleContext.updatec                    sn   t dt|dd i}t i }d|d< d|d< | jjd| j||d	I d
H }t| j|| jd | jd dS )rB   rf   c                 S   s   | S rg   r   rh   r   r   r   rj   !  rk   z*RoleContext.update_async.<locals>.<lambda>rl   rm   rb   rc   rn   ro   Nr   r   r%   )	r   r`   r   rq   r1   rC   rZ   r   r)   rr   r   r   r   rC     s(    	 
   zRoleContext.update_asyncc                 C   s$   d dd | j D }d|S )rD   rE   c                 s   s   | ]\}}d  ||V  qdS rF   rG   rI   r   r   r   rM   ;  s     z'RoleContext.__repr__.<locals>.<genexpr>z&<Twilio.IpMessaging.V2.RoleContext {}>rN   rQ   r   r   r   rS   5  s    zRoleContext.__repr__)r   r   r   r   rU   r'   rW   r5   r7   r   r9   r;   r   r@   rC   rS   rX   r   r   r,   r   r.      s   r.   c                   @   s2   e Zd Zeeef edddZedddZdS )RolePage)r   r0   c                 C   s   t | j|| jd dS )zj
        Build an instance of RoleInstance

        :param payload: Payload response from the API
        r   r   )r   r1   r)   )r+   r   r   r   r   get_instanceA  s
      zRolePage.get_instancer/   c                 C   s   dS )rD   z <Twilio.IpMessaging.V2.RolePage>r   r2   r   r   r   rS   K  s    zRolePage.__repr__N)	r   r   r   r   rU   r   r   ru   rS   r   r   r   r   rs   ?  s   
rs   c                       s  e Zd Zeed fddZedee edddZedee eddd	Z	d&e
e e
e ee dddZd'e
e e
e ee dddZd(e
e e
e ee dddZd)e
e e
e ee dddZejejejfeeef eeef eeef edddZejejejfeeef eeef eeef edddZeedddZeedddZeeddd Zeedd!d"Zed#d$d%Z  ZS )*RoleList)r   r   c                    s*   t  | d|i| _djf | j| _dS )z
        Initialize the RoleList

        :param version: Version that contains the resource
        :param service_sid:

        r   z/Services/{service_sid}/RolesNrY   )r+   r   r   r,   r   r   r'   V  s
     zRoleList.__init__r   )r   r    r=   r0   c              	   C   sh   t ||t|dd d}t ddi}d|d< d|d< | jjd| j||d	}t| j|| jd
 dS )z
        Create the RoleInstance

        :param friendly_name:
        :param type:
        :param permission:

        :returns: The created RoleInstance
        c                 S   s   | S rg   r   rh   r   r   r   rj   w  rk   z!RoleList.create.<locals>.<lambda>ZFriendlyNameTyperf   rm   rl   rb   rc   rn   ro   r   rt   )	r   r`   r   rq   r1   createrZ   r   r)   r+   r   r    r=   rp   r_   r   r   r   r   ry   f  s(         zRoleList.createc              	      sn   t ||t|dd d}t ddi}d|d< d|d< | jjd| j||d	I d
H }t| j|| jd dS )z
        Asynchronously create the RoleInstance

        :param friendly_name:
        :param type:
        :param permission:

        :returns: The created RoleInstance
        c                 S   s   | S rg   r   rh   r   r   r   rj     rk   z'RoleList.create_async.<locals>.<lambda>rw   rm   rl   rb   rc   rn   ro   Nr   rt   )	r   r`   r   rq   r1   create_asyncrZ   r   r)   rz   r   r   r   r{     s(         zRoleList.create_asyncN)limit	page_sizer0   c                 C   s0   | j ||}| j|d d}| j ||d S )aZ  
        Streams RoleInstance records from the API as a generator stream.
        This operation lazily loads records as efficiently as possible until the limit
        is reached.
        The results are returned as a generator, so this operation is memory efficient.

        :param limit: Upper limit for the number of records to return. stream()
                      guarantees to never return more than limit.  Default is no limit
        :param page_size: Number of records to fetch per request, when not set will use
                          the default value of 50 records.  If no page_size is defined
                          but a limit is defined, stream() will attempt to read the
                          limit with the most efficient page size, i.e. min(limit, 1000)

        :returns: Generator that will yield up to limit results
        r}   r}   r|   )r1   read_limitspagestreamr+   r|   r}   Zlimitsr   r   r   r   r     s    zRoleList.streamc                    s6   | j ||}| j|d dI dH }| j ||d S )ai  
        Asynchronously streams RoleInstance records from the API as a generator stream.
        This operation lazily loads records as efficiently as possible until the limit
        is reached.
        The results are returned as a generator, so this operation is memory efficient.

        :param limit: Upper limit for the number of records to return. stream()
                      guarantees to never return more than limit.  Default is no limit
        :param page_size: Number of records to fetch per request, when not set will use
                          the default value of 50 records.  If no page_size is defined
                          but a limit is defined, stream() will attempt to read the
                          limit with the most efficient page size, i.e. min(limit, 1000)

        :returns: Generator that will yield up to limit results
        r}   r~   Nr|   )r1   r   
page_asyncstream_asyncr   r   r   r   r     s    zRoleList.stream_asyncc                 C   s   t | j||dS )a  
        Lists RoleInstance records from the API as a list.
        Unlike stream(), this operation is eager and will load `limit` records into
        memory before returning.

        :param limit: Upper limit for the number of records to return. list() guarantees
                      never to return more than limit.  Default is no limit
        :param page_size: Number of records to fetch per request, when not set will use
                          the default value of 50 records.  If no page_size is defined
                          but a limit is defined, list() will attempt to read the limit
                          with the most efficient page size, i.e. min(limit, 1000)

        :returns: list that will contain up to limit results
        r|   r}   )listr   r+   r|   r}   r   r   r   r     s    zRoleList.listc                    s$   dd | j ||dI dH 2 I dH S )a  
        Asynchronously lists RoleInstance records from the API as a list.
        Unlike stream(), this operation is eager and will load `limit` records into
        memory before returning.

        :param limit: Upper limit for the number of records to return. list() guarantees
                      never to return more than limit.  Default is no limit
        :param page_size: Number of records to fetch per request, when not set will use
                          the default value of 50 records.  If no page_size is defined
                          but a limit is defined, list() will attempt to read the limit
                          with the most efficient page size, i.e. min(limit, 1000)

        :returns: list that will contain up to limit results
        c                    s   g | z3 d H W }|q6 S rg   r   )rJ   recordr   r   r   
<listcomp>	  s   z'RoleList.list_async.<locals>.<listcomp>r   N)r   r   r   r   r   
list_async  s    
zRoleList.list_async)
page_tokenpage_numberr}   r0   c                 C   sN   t |||d}t ddi}d|d< | jjd| j||d}t| j|| jS )am  
        Retrieve a single page of RoleInstance records from the API.
        Request is executed immediately

        :param page_token: PageToken provided by the API
        :param page_number: Page Number, this value is simply for client state
        :param page_size: Number of records to return, defaults to 50

        :returns: Page of RoleInstance
        Z	PageTokenr   ZPageSizerm   rl   rb   rc   rd   r]   r^   paramsr_   )r   r`   r1   r   rZ   rs   r)   r+   r   r   r}   rp   r_   responser   r   r   r     s       zRoleList.pagec                    sT   t |||d}t ddi}d|d< | jjd| j||dI dH }t| j|| jS )	a|  
        Asynchronously retrieve a single page of RoleInstance records from the API.
        Request is executed immediately

        :param page_token: PageToken provided by the API
        :param page_number: Page Number, this value is simply for client state
        :param page_size: Number of records to return, defaults to 50

        :returns: Page of RoleInstance
        r   rm   rl   rb   rc   rd   r   N)r   r`   r1   r   rZ   rs   r)   r   r   r   r   r   2  s       zRoleList.page_async)
target_urlr0   c                 C   s"   | j jjd|}t| j || jS )z
        Retrieve a specific page of RoleInstance records from the API.
        Request is executed immediately

        :param target_url: API-generated URL for the requested results page

        :returns: Page of RoleInstance
        rd   )r1   domaintwiliorequestrs   r)   r+   r   r   r   r   r   get_pageS  s    	zRoleList.get_pagec                    s(   | j jjd|I dH }t| j || jS )z
        Asynchronously retrieve a specific page of RoleInstance records from the API.
        Request is executed immediately

        :param target_url: API-generated URL for the requested results page

        :returns: Page of RoleInstance
        rd   N)r1   r   r   Zrequest_asyncrs   r)   r   r   r   r   get_page_async_  s    	zRoleList.get_page_async)r   r0   c                 C   s   t | j| jd |dS z?
        Constructs a RoleContext

        :param sid:
        r   r%   r.   r1   r)   r+   r   r   r   r   r(   k  s
      zRoleList.getc                 C   s   t | j| jd |dS r   r   r   r   r   r   __call__u  s
      zRoleList.__call__r/   c                 C   s   dS )rD   z <Twilio.IpMessaging.V2.RoleList>r   r2   r   r   r   rS     s    zRoleList.__repr__)NN)NN)NN)NN) r   r   r   r   rU   r'   r   r   ry   r{   r   intr   r   r	   r   r   r   r   unsetr   rT   rs   r   r   r   r   r.   r(   r   rS   rX   r   r   r,   r   rv   T  s|     #  $        


#


!

rv   N)__doc__r   typingr   r   r   r   r   r   r	   Ztwilio.baser
   r   r   Ztwilio.base.instance_contextr   Ztwilio.base.instance_resourcer   Ztwilio.base.list_resourcer   Ztwilio.base.versionr   Ztwilio.base.pager   r   r.   rs   rv   r   r   r   r   <module>   s   $  "