o
    e_K                     @   s   d 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 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 )za
This code was generated by
\ / _    _  _|   _  _
 | (_)\/(_)(_|\/| |(/_  v1.0.0
      /       /
    )deserialize)values)InstanceContext)InstanceResource)ListResource)Pagec                       s   e Zd ZdZ fddZejejejddfddZejejejddfddZejejejejejejfd	d
Z	dd Z
ejejejfddZdd Zdd Zdd Z  ZS )	QueryList PLEASE NOTE that this class contains preview products that are subject
    to change. Use them with caution. If you currently do not have developer
    preview access, please contact help@twilio.com. c                    s2   t t| | d|i| _djdi | j| _dS )aH  
        Initialize the QueryList

        :param Version version: Version that contains the resource
        :param assistant_sid: The unique ID of the parent Assistant.

        :returns: twilio.rest.preview.understand.assistant.query.QueryList
        :rtype: twilio.rest.preview.understand.assistant.query.QueryList
        assistant_sidz#/Assistants/{assistant_sid}/QueriesN )superr   __init__	_solutionformat_uri)selfversionr
   	__class__r   a/var/www/html/venv/lib/python3.10/site-packages/twilio/rest/preview/understand/assistant/query.pyr      s   

zQueryList.__init__Nc                 C   s6   | j ||}| j||||d d}| j ||d S )a  
        Streams QueryInstance 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 unicode language: An ISO language-country string of the sample.
        :param unicode model_build: The Model Build Sid or unique name of the Model Build to be queried.
        :param unicode status: A string that described the query status. The values can be: pending_review, reviewed, discarded
        :param int limit: Upper limit for the number of records to return. stream()
                          guarantees to never return more than limit.  Default is no limit
        :param int 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
        :rtype: list[twilio.rest.preview.understand.assistant.query.QueryInstance]
        	page_size)languagemodel_buildstatusr   limit)_versionread_limitspagestream)r   r   r   r   r   r   limitsr   r   r   r   r   &   s   zQueryList.streamc                 C   s   t | j|||||dS )a  
        Lists QueryInstance records from the API as a list.
        Unlike stream(), this operation is eager and will load `limit` records into
        memory before returning.

        :param unicode language: An ISO language-country string of the sample.
        :param unicode model_build: The Model Build Sid or unique name of the Model Build to be queried.
        :param unicode status: A string that described the query status. The values can be: pending_review, reviewed, discarded
        :param int limit: Upper limit for the number of records to return. list() guarantees
                          never to return more than limit.  Default is no limit
        :param int 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: Generator that will yield up to limit results
        :rtype: list[twilio.rest.preview.understand.assistant.query.QueryInstance]
        )r   r   r   r   r   )listr   )r   r   r   r   r   r   r   r   r   r    F   s   zQueryList.listc           	   	   C   s<   t ||||||d}| jjd| j|d}t| j|| jS )a  
        Retrieve a single page of QueryInstance records from the API.
        Request is executed immediately

        :param unicode language: An ISO language-country string of the sample.
        :param unicode model_build: The Model Build Sid or unique name of the Model Build to be queried.
        :param unicode status: A string that described the query status. The values can be: pending_review, reviewed, discarded
        :param str page_token: PageToken provided by the API
        :param int page_number: Page Number, this value is simply for client state
        :param int page_size: Number of records to return, defaults to 50

        :returns: Page of QueryInstance
        :rtype: twilio.rest.preview.understand.assistant.query.QueryPage
        )Language
ModelBuildStatus	PageTokenr   PageSizeGET)methoduriparams)r   ofr   r   r   	QueryPager   )	r   r   r   r   
page_tokenpage_numberr   dataresponser   r   r   r   b   s   	zQueryList.pagec                 C   s"   | j jjd|}t| j || jS )a<  
        Retrieve a specific page of QueryInstance records from the API.
        Request is executed immediately

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

        :returns: Page of QueryInstance
        :rtype: twilio.rest.preview.understand.assistant.query.QueryPage
        r&   )r   domaintwiliorequestr+   r   )r   
target_urlr/   r   r   r   get_page   s
   

zQueryList.get_pagec                 C   s@   t |||||d}| jjd| j|d}t| j|| jd dS )a  
        Create the QueryInstance

        :param unicode language: An ISO language-country string of the sample.
        :param unicode query: A user-provided string that uniquely identifies this resource as an alternative to the sid. It can be up to 2048 characters long.
        :param unicode tasks: Constraints the query to a set of tasks. Useful when you need to constrain the paths the user can take. Tasks should be comma separated task-unique-name-1, task-unique-name-2
        :param unicode model_build: The Model Build Sid or unique name of the Model Build to be queried.
        :param unicode field: Constraints the query to a given Field with an task. Useful when you know the Field you are expecting. It accepts one field in the format task-unique-name-1:field-unique-name

        :returns: The created QueryInstance
        :rtype: twilio.rest.preview.understand.assistant.query.QueryInstance
        )r!   QueryTasksr"   FieldPOSTr'   r(   r.   r
   r
   )r   r*   r   creater   QueryInstancer   )r   r   querytasksr   fieldr.   payloadr   r   r   r;      s   zQueryList.createc                 C      t | j| jd |dS a  
        Constructs a QueryContext

        :param sid: A 34 character string that uniquely identifies this resource.

        :returns: twilio.rest.preview.understand.assistant.query.QueryContext
        :rtype: twilio.rest.preview.understand.assistant.query.QueryContext
        r
   r
   sidQueryContextr   r   r   rD   r   r   r   get      	zQueryList.getc                 C   rA   rB   rE   rG   r   r   r   __call__   rI   zQueryList.__call__c                 C      dS )z
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        z%<Twilio.Preview.Understand.QueryList>r   r   r   r   r   __repr__      zQueryList.__repr__)__name__
__module____qualname____doc__r   r   unsetr   r    r   r4   r;   rH   rJ   rN   __classcell__r   r   r   r   r      s(    
 


r   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )r+   r	   c                    s   t t| || || _dS )a  
        Initialize the QueryPage

        :param Version version: Version that contains the resource
        :param Response response: Response from the API
        :param assistant_sid: The unique ID of the parent Assistant.

        :returns: twilio.rest.preview.understand.assistant.query.QueryPage
        :rtype: twilio.rest.preview.understand.assistant.query.QueryPage
        N)r   r+   r   r   )r   r   r/   solutionr   r   r   r      s   
zQueryPage.__init__c                 C   s   t | j|| jd dS )a  
        Build an instance of QueryInstance

        :param dict payload: Payload response from the API

        :returns: twilio.rest.preview.understand.assistant.query.QueryInstance
        :rtype: twilio.rest.preview.understand.assistant.query.QueryInstance
        r
   r:   )r<   r   r   r   r@   r   r   r   get_instance   rI   zQueryPage.get_instancec                 C   rK   )rL   z%<Twilio.Preview.Understand.QueryPage>r   rM   r   r   r   rN      rO   zQueryPage.__repr__)rP   rQ   rR   rS   r   rX   rN   rU   r   r   r   r   r+      s
    r+   c                       sJ   e Zd ZdZ fddZdd ZejejfddZdd	 Z	d
d Z
  ZS )rF   r	   c                    s4   t t| | ||d| _djdi | j| _dS )a  
        Initialize the QueryContext

        :param Version version: Version that contains the resource
        :param assistant_sid: The unique ID of the Assistant.
        :param sid: A 34 character string that uniquely identifies this resource.

        :returns: twilio.rest.preview.understand.assistant.query.QueryContext
        :rtype: twilio.rest.preview.understand.assistant.query.QueryContext
        rC   z)/Assistants/{assistant_sid}/Queries/{sid}Nr   )r   rF   r   r   r   r   )r   r   r
   rD   r   r   r   r      s   zQueryContext.__init__c                 C   s0   | j jd| jd}t| j || jd | jd dS )
        Fetch the QueryInstance

        :returns: The fetched QueryInstance
        :rtype: twilio.rest.preview.understand.assistant.query.QueryInstance
        r&   r'   r(   r
   rD   rC   )r   fetchr   r<   r   rW   r   r   r   r[     s   zQueryContext.fetchc                 C   sB   t ||d}| jjd| j|d}t| j|| jd | jd dS )  
        Update the QueryInstance

        :param unicode sample_sid: An optional reference to the Sample created from this query.
        :param unicode status: A string that described the query status. The values can be: pending_review, reviewed, discarded

        :returns: The updated QueryInstance
        :rtype: twilio.rest.preview.understand.assistant.query.QueryInstance
        )	SampleSidr#   r8   r9   r
   rD   rC   )r   r*   r   updater   r<   r   )r   
sample_sidr   r.   r@   r   r   r   r^     s   
zQueryContext.updatec                 C   s   | j jd| jdS )|
        Deletes the QueryInstance

        :returns: True if delete succeeds, False otherwise
        :rtype: bool
        DELETErZ   )r   deleter   rM   r   r   r   rb   0  s   zQueryContext.deletec                 C   $   d dd | j D }d|S )rL    c                 s        | ]\}}d  ||V  qdS z{}={}Nr   .0kvr   r   r   	<genexpr>@      z(QueryContext.__repr__.<locals>.<genexpr>z+<Twilio.Preview.Understand.QueryContext {}>joinr   itemsr   r   contextr   r   r   rN   9     
zQueryContext.__repr__)rP   rQ   rR   rS   r   r[   r   rT   r^   rb   rN   rU   r   r   r   r   rF      s    	rF   c                       s   e Zd ZdZd) fdd	Zedd Zedd Zed	d
 Zedd Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd  Zd!d" Zejejfd#d$Zd%d& Zd'd( Z  ZS )*r<   r	   Nc                    s   t t| | |dt|dt|d|d|d|d|d|d|d	|d
|d|d|dd| _d| _||pP| jd
 d| _dS )z
        Initialize the QueryInstance

        :returns: twilio.rest.preview.understand.assistant.query.QueryInstance
        :rtype: twilio.rest.preview.understand.assistant.query.QueryInstance
        account_siddate_createddate_updatedresultsr   model_build_sidr=   r_   r
   rD   r   urlsource_channel)rt   ru   rv   rw   r   rx   r=   r_   r
   rD   r   ry   rz   NrC   )	r   r<   r   rH   r   iso8601_datetime_properties_contextr   )r   r   r@   r
   rD   r   r   r   r   I  s"   zQueryInstance.__init__c                 C   s.   | j du rt| j| jd | jd d| _ | j S )a2  
        Generate an instance context for the instance, the context is capable of
        performing various actions.  All instance actions are proxied to the context

        :returns: QueryContext for this QueryInstance
        :rtype: twilio.rest.preview.understand.assistant.query.QueryContext
        Nr
   rD   rC   )r}   rF   r   r   rM   r   r   r   _proxyg  s   
	zQueryInstance._proxyc                 C   
   | j d S )zi
        :returns: The unique ID of the Account that created this Query.
        :rtype: unicode
        rt   r|   rM   r   r   r   rt   x     
zQueryInstance.account_sidc                 C   r   )z\
        :returns: The date that this resource was created
        :rtype: datetime
        ru   r   rM   r   r   r   ru     r   zQueryInstance.date_createdc                 C   r   )za
        :returns: The date that this resource was last updated
        :rtype: datetime
        rv   r   rM   r   r   r   rv     r   zQueryInstance.date_updatedc                 C   r   )z
        :returns: The natural language analysis results which include the Task recognized, the confidence score and a list of identified Fields.
        :rtype: dict
        rw   r   rM   r   r   r   rw     r   zQueryInstance.resultsc                 C   r   )za
        :returns: An ISO language-country string of the sample.
        :rtype: unicode
        r   r   rM   r   r   r   r     r   zQueryInstance.languagec                 C   r   )z]
        :returns: The unique ID of the Model Build queried.
        :rtype: unicode
        rx   r   rM   r   r   r   rx     r   zQueryInstance.model_build_sidc                 C   r   )zZ
        :returns: The end-user's natural language input.
        :rtype: unicode
        r=   r   rM   r   r   r   r=     r   zQueryInstance.queryc                 C   r   )zp
        :returns: An optional reference to the Sample created from this query.
        :rtype: unicode
        r_   r   rM   r   r   r   r_     r   zQueryInstance.sample_sidc                 C   r   )zZ
        :returns: The unique ID of the parent Assistant.
        :rtype: unicode
        r
   r   rM   r   r   r   r
     r   zQueryInstance.assistant_sidc                 C   r   )zq
        :returns: A 34 character string that uniquely identifies this resource.
        :rtype: unicode
        rD   r   rM   r   r   r   rD     r   zQueryInstance.sidc                 C   r   )z
        :returns: A string that described the query status. The values can be: pending_review, reviewed, discarded
        :rtype: unicode
        r   r   rM   r   r   r   r     r   zQueryInstance.statusc                 C   r   )z;
        :returns: The url
        :rtype: unicode
        ry   r   rM   r   r   r   ry     r   zQueryInstance.urlc                 C   r   )zq
        :returns: The communication channel where this end-user input came from
        :rtype: unicode
        rz   r   rM   r   r   r   rz     r   zQueryInstance.source_channelc                 C   
   | j  S )rY   )r~   r[   rM   r   r   r   r[        
zQueryInstance.fetchc                 C   s   | j j||dS )r\   )r_   r   )r~   r^   )r   r_   r   r   r   r   r^     s   
zQueryInstance.updatec                 C   r   )r`   )r~   rb   rM   r   r   r   rb     r   zQueryInstance.deletec                 C   rc   )rL   rd   c                 s   re   rf   rg   rh   r   r   r   rl     rm   z)QueryInstance.__repr__.<locals>.<genexpr>z,<Twilio.Preview.Understand.QueryInstance {}>rn   rq   r   r   r   rN     rs   zQueryInstance.__repr__)N)rP   rQ   rR   rS   r   propertyr~   rt   ru   rv   rw   r   rx   r=   r_   r
   rD   r   ry   rz   r[   r   rT   r^   rb   rN   rU   r   r   r   r   r<   D  sF    













		r<   N)rS   twilio.baser   r   twilio.base.instance_contextr   twilio.base.instance_resourcer   twilio.base.list_resourcer   twilio.base.pager   r   r+   rF   r<   r   r   r   r   <module>   s    ;*O