U
    k7gxl                     @   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 - Chat
    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                	       sd  e Zd ZG dd deZdeeeef 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jejejejejejfeeef eeef eeef eeef eeef eeef d dddZejejejejejejfeeef eeef eeef eeef eeef eeef d dddZedddZ  ZS )CredentialInstancec                   @   s   e Zd ZdZdZdZdS )CredentialInstance.PushServiceZgcmZapnZfcmN)__name__
__module____qualname__ZGCMZAPNZFCM r   r   B/tmp/pip-unpacked-wheel-qtbjxrb6/twilio/rest/chat/v2/credential.pyPushService   s   r   N)versionpayloadsidc                    s   t  | |d| _|d| _|d| _|d| _|d| _t	|d| _
t	|d| _|d| _d|p| ji| _d | _d S )	Nr   account_sidfriendly_nametypesandboxdate_createddate_updatedurl)super__init__getr   r   r   r   r    r
   iso8601_datetimer!   r"   r#   	_solution_context)selfr   r   r   	__class__r   r   r%   +   s"     zCredentialInstance.__init__CredentialContextreturnc                 C   s&   | j dkr t| j| 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: CredentialContext for this CredentialInstance
        Nr   r   )r)   r-   _versionr(   r*   r   r   r   _proxyB   s    
zCredentialInstance._proxyc                 C   s
   | j  S )m
        Deletes the CredentialInstance


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


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


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


        :returns: The fetched CredentialInstance
        N)r3   fetch_asyncr2   r   r   r   r;   l   s    zCredentialInstance.fetch_asyncr   certificateprivate_keyr    api_keysecretr/   c                 C   s   | j j||||||dS )N  
        Update the CredentialInstance

        :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
        :param certificate: [APN only] The URL encoded representation of the certificate. For example,  `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`
        :param private_key: [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`
        :param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
        :param api_key: [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
        :param secret: [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.

        :returns: The updated CredentialInstance
        r   r=   r>   r    r?   r@   )r3   updater*   r   r=   r>   r    r?   r@   r   r   r   rC   u   s    zCredentialInstance.updatec                    s   | j j||||||dI dH S )h  
        Asynchronous coroutine to update the CredentialInstance

        :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
        :param certificate: [APN only] The URL encoded representation of the certificate. For example,  `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`
        :param private_key: [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`
        :param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
        :param api_key: [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
        :param secret: [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.

        :returns: The updated CredentialInstance
        rB   N)r3   update_asyncrD   r   r   r   rF      s    zCredentialInstance.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.CredentialInstance.__repr__.<locals>.<genexpr>z&<Twilio.Chat.V2.CredentialInstance {}>joinr(   itemsrK   r*   contextr   r   r   __repr__   s    zCredentialInstance.__repr__)N)r   r   r   objectr   r   r   strr   r   r%   propertyr3   boolr5   r7   r9   r;   r   unsetr   rC   rF   rV   __classcell__r   r   r+   r   r      sX     
 			





 





r   c                	       s2  e Zd Z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jejejejejejfeeef eeef eeef eeef eeef eeef e	dddZejejejejejejfeeef eeef eeef eeef eeef eeef e	dddZedddZ  ZS )r-   )r   r   c                    s*   t  | d|i| _djf | j| _dS )z
        Initialize the CredentialContext

        :param version: Version that contains the resource
        :param sid: The SID of the Credential resource to update.
        r   z/Credentials/{sid}N)r$   r%   r(   rK   _uri)r*   r   r   r+   r   r   r%      s
     zCredentialContext.__init__r.   c                 C   s   | j jd| jdS )r4   DELETEmethoduri)r1   r5   r]   r2   r   r   r   r5      s    zCredentialContext.deletec                    s   | j jd| jdI dH S )r6   r^   r_   N)r1   r7   r]   r2   r   r   r   r7      s    zCredentialContext.delete_asyncc                 C   s(   | j jd| jd}t| j || jd dS )r8   GETr_   r   r0   )r1   r9   r]   r   r(   r*   r   r   r   r   r9      s    zCredentialContext.fetchc                    s.   | j jd| jdI dH }t| j || jd dS )r:   rb   r_   Nr   r0   )r1   r;   r]   r   r(   rc   r   r   r   r;      s    zCredentialContext.fetch_asyncr<   c           	   	   C   sH   t |||t|||d}| jjd| j|d}t| j|| jd dS )rA   FriendlyNameCertificate
PrivateKeySandboxApiKeySecretPOSTr`   ra   datar   r0   )	r   ofr   boolean_to_stringr1   rC   r]   r   r(   	r*   r   r=   r>   r    r?   r@   rm   r   r   r   r   rC   
  s    zCredentialContext.updatec           	   	      sN   t |||t|||d}| jjd| j|dI dH }t| j|| jd dS )rE   rd   rk   rl   Nr   r0   )	r   rn   r   ro   r1   rF   r]   r   r(   rp   r   r   r   rF   2  s    zCredentialContext.update_asyncc                 C   s$   d dd | j D }d|S )rG   rH   c                 s   s   | ]\}}d  ||V  qdS rI   rJ   rL   r   r   r   rP   `  s     z-CredentialContext.__repr__.<locals>.<genexpr>z%<Twilio.Chat.V2.CredentialContext {}>rQ   rT   r   r   r   rV   Z  s    zCredentialContext.__repr__)r   r   r   r   rX   r%   rZ   r5   r7   r   r9   r;   r   r[   r   rW   rC   rF   rV   r\   r   r   r+   r   r-      sH   





*





(r-   c                   @   s2   e Zd Zeeef edddZedddZdS )CredentialPage)r   r/   c                 C   s   t | j|S )zp
        Build an instance of CredentialInstance

        :param payload: Payload response from the API
        )r   r1   rc   r   r   r   get_instancef  s    zCredentialPage.get_instancer.   c                 C   s   dS )rG   z<Twilio.Chat.V2.CredentialPage>r   r2   r   r   r   rV   n  s    zCredentialPage.__repr__N)	r   r   r   r   rX   r   r   rr   rV   r   r   r   r   rq   d  s   rq   c                
       s0  e Zd Zed fddZejejejejejejfdeee	f eee	f eee	f ee
e	f eee	f eee	f edddZejejejejejejfdeee	f eee	f eee	f ee
e	f eee	f eee	f 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 )*CredentialList)r   c                    s   t  | d| _dS )zl
        Initialize the CredentialList

        :param version: Version that contains the resource

        z/CredentialsN)r$   r%   r]   )r*   r   r+   r   r   r%   y  s    zCredentialList.__init__r   )r   r   r=   r>   r    r?   r@   r/   c              
   C   sP   t ||||t|||d}t ddi}	| jjd| j||	d}
t| j|
S )ag  
        Create the CredentialInstance

        :param type:
        :param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
        :param certificate: [APN only] The URL encoded representation of the certificate. For example,  `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`
        :param private_key: [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`
        :param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
        :param api_key: [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
        :param secret: [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.

        :returns: The created CredentialInstance
        Typere   rf   rg   rh   ri   rj   Content-Type!application/x-www-form-urlencodedrk   r`   ra   rm   headers)r   rn   r   ro   r1   creater]   r   r*   r   r   r=   r>   r    r?   r@   rm   ry   r   r   r   r   rz     s$       zCredentialList.createc              
      sV   t ||||t|||d}t ddi}	| jjd| j||	dI dH }
t| j|
S )av  
        Asynchronously create the CredentialInstance

        :param type:
        :param friendly_name: A descriptive string that you create to describe the new resource. It can be up to 64 characters long.
        :param certificate: [APN only] The URL encoded representation of the certificate. For example,  `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----`
        :param private_key: [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----`
        :param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
        :param api_key: [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.
        :param secret: [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.

        :returns: The created CredentialInstance
        rt   rv   rw   rk   rx   N)r   rn   r   ro   r1   create_asyncr]   r   r{   r   r   r   r|     s$       zCredentialList.create_asyncN)limit	page_sizer/   c                 C   s0   | j ||}| j|d d}| j ||d S )a`  
        Streams CredentialInstance 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CredentialList.streamc                    s6   | j ||}| j|d dI dH }| j ||d S )ao  
        Asynchronously streams CredentialInstance 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CredentialList.stream_asyncc                 C   s   t | j||dS )a  
        Lists CredentialInstance 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CredentialList.listc                    s$   dd | j ||dI dH 2 I dH S )a  
        Asynchronously lists CredentialInstance 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 )Nr   )rM   recordr   r   r   
<listcomp>9  s   z-CredentialList.list_async.<locals>.<listcomp>r   N)r   r   r   r   r   
list_async&  s    
zCredentialList.list_async)
page_tokenpage_numberr~   r/   c                 C   s2   t |||d}| jjd| j|d}t| j|S )ay  
        Retrieve a single page of CredentialInstance 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 CredentialInstance
        Z	PageTokenr   ZPageSizerb   r`   ra   params)r   rn   r1   r   r]   rq   r*   r   r   r~   rm   responser   r   r   r   A  s    zCredentialList.pagec                    s8   t |||d}| jjd| j|dI dH }t| j|S )a  
        Asynchronously retrieve a single page of CredentialInstance 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 CredentialInstance
        r   rb   r   N)r   rn   r1   r   r]   rq   r   r   r   r   r   \  s      zCredentialList.page_async)
target_urlr/   c                 C   s   | j jjd|}t| j |S )z
        Retrieve a specific page of CredentialInstance records from the API.
        Request is executed immediately

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

        :returns: Page of CredentialInstance
        rb   )r1   domaintwiliorequestrq   r*   r   r   r   r   r   get_pagey  s    	zCredentialList.get_pagec                    s$   | j jjd|I dH }t| j |S )a  
        Asynchronously retrieve a specific page of CredentialInstance records from the API.
        Request is executed immediately

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

        :returns: Page of CredentialInstance
        rb   N)r1   r   r   Zrequest_asyncrq   r   r   r   r   get_page_async  s    	zCredentialList.get_page_async)r   r/   c                 C   s   t | j|dS zs
        Constructs a CredentialContext

        :param sid: The SID of the Credential resource to update.
        r0   r-   r1   r*   r   r   r   r   r&     s    zCredentialList.getc                 C   s   t | j|dS r   r   r   r   r   r   __call__  s    zCredentialList.__call__r.   c                 C   s   dS )rG   z<Twilio.Chat.V2.CredentialList>r   r2   r   r   r   rV     s    zCredentialList.__repr__)NN)NN)NN)NN)!r   r   r   r   r%   r   r[   r   rX   rW   rZ   r   rz   r|   r   intr   r   r	   r   r   r   r   rq   r   r   r   r   r-   r&   r   rV   r\   r   r   r+   r   rs   w  s   





.





-        





rs   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-   rq   rs   r   r   r   r   <module>   s   $ # *