Ë
    ?—ÖjÊ  ã                   ó¦   — d Z ddlmZ ddlmZ ddlmZ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e	«      Z G d„ de«      Z eedg d¢¬«      Zy)z=TimestreamQueryBackend class with methods for supported APIs.é    )ÚAny)Úuuid4)ÚBackendDictÚBaseBackend)Ú	BaseModel)Ú	unix_time)Úget_partitioné   )ÚResourceNotFoundc                   óº   — e Zd Zdededededeeef   deeeeef   f   deeef   dz  d	ed
eeeef      dz  dedz  deeeeef   f   dz  fd„Zdeeef   fd„Zy)ÚScheduledQueryÚ
account_idÚregion_nameÚnameÚquery_stringÚschedule_configurationÚnotification_configurationÚtarget_configurationNÚ"scheduled_query_execution_role_arnÚtagsÚ
kms_key_idÚerror_report_configurationc                 ó   — || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        t        «       | _        t        «       | _        dt        |«      › d|› d|› d|› �| _        d| _        y )Nzarn:z:timestream:ú:z:scheduled-query/ÚENABLED)r   r   r   r   r   r   r   r   r   r   r   r   Ú
created_onÚ
updated_onr	   ÚarnÚstate)Úselfr   r   r   r   r   r   r   r   r   r   r   s               úX/var/www/photos/backend/venv/lib/python3.12/site-packages/moto/timestreamquery/models.pyÚ__init__zScheduledQuery.__init__   s›   € ð %ˆŒØ&ˆÔØˆŒ	Ø(ˆÔØ&<ˆÔ#Ø*DˆÔ'Ø$8ˆÔ!Ø2TˆÔ/ØˆŒ	Ø$ˆŒØ*DˆÔ'ä#›+ˆŒÜ#›+ˆŒàœ-¨Ó4Ð5°\À+ÀÈaÐPZÈ|Ð[lÐmqÐlrÐsˆŒØˆ�
ó    Úreturnc                 óú   — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  dœS )N)ÚArnÚNameÚCreationTimeÚStateÚQueryStringÚScheduleConfigurationÚNotificationConfigurationÚTargetConfigurationÚScheduledQueryExecutionRoleArnÚKmsKeyIdÚErrorReportConfiguration)r   r   r   r   r   r   r   r   r   r   r   ©r    s    r!   ÚdescriptionzScheduledQuery.description/   se   € à—8‘8Ø—I‘IØ ŸO™OØ—Z‘ZØ×,Ñ,Ø%)×%@Ñ%@Ø)-×)HÑ)HØ#'×#<Ñ#<Ø.2×.UÑ.UØŸ™Ø(,×(GÑ(Gñ
ð 	
r#   )	Ú__name__Ú
__module__Ú__qualname__ÚstrÚdictr   Úlistr"   r2   © r#   r!   r   r      sÜ   „ ðàðð ðð ð	ð
 ðð !% S¨# X¡ðð %)¨¨d°3¸°8©nÐ)<Ñ$=ðð # 3¨ 8™n¨tÑ3ðð -0ðð �4˜˜S˜‘>Ñ" TÑ)ðð ˜$‘Jðð %)¨¨d°3¸°8©nÐ)<Ñ$=ÀÑ$Dóð@
˜T # s (™^ô 
r#   r   c                   ó*  ‡ — e Zd ZdZdedefˆ fd„Zdededeeef   deeeeef   f   d	eeef   d
z  dedeeeef      d
z  ded
z  deeeeef   f   de	fd„Z
dedd
fd„Zdede	fd„Zdededd
fd„Zdedeeef   fd„Zdeeeeez  f      fd„Zˆ xZS )ÚTimestreamQueryBackendz'Implementation of TimestreamQuery APIs.r   r   c                 óP   •— t         ‰| �  ||«       i | _        i | _        i | _        y ©N)Úsuperr"   Úscheduled_queriesÚquery_result_queueÚquery_results)r    r   r   Ú	__class__s      €r!   r"   zTimestreamQueryBackend.__init__B   s*   ø€ Ü‰Ñ˜ jÔ1Ø<>ˆÔàJLˆÔØ8:ˆÕr#   r   r   r   r   r   Nr   r   r   r   r$   c
                 óŒ   — t        | j                  | j                  |||||||||	¬«      }
|
| j                  |
j                  <   |
S )N)r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r?   r   )r    r   r   r   r   r   r   r   r   r   Úquerys              r!   Úcreate_scheduled_queryz-TimestreamQueryBackend.create_scheduled_queryI   sT   € ô Ø—‘Ø×(Ñ(ØØ%Ø#9Ø'AØ!5Ø/QØØ!Ø'Aô
ˆð -2ˆ×Ñ˜uŸy™yÑ)Øˆr#   Úscheduled_query_arnc                 ó<   — | j                   j                  |d «       y r=   )r?   Úpop©r    rF   s     r!   Údelete_scheduled_queryz-TimestreamQueryBackend.delete_scheduled_querye   s   € Ø×Ñ×"Ñ"Ð#6¸Õ=r#   c                 óR   — || j                   vrt        |«      ‚| j                   |   S r=   )r?   r   rI   s     r!   Údescribe_scheduled_queryz/TimestreamQueryBackend.describe_scheduled_queryh   s.   € Ø d×&<Ñ&<Ñ<Ü"Ð#6Ó7Ð7Ø×%Ñ%Ð&9Ñ:Ð:r#   r   c                 ó0   — | j                   |   }||_        y r=   )r?   r   )r    rF   r   rD   s       r!   Úupdate_scheduled_queryz-TimestreamQueryBackend.update_scheduled_querym   s   € Ø×&Ñ&Ð':Ñ;ˆØˆ�r#   c                 óŠ  — | j                   j                  |«      r| j                   |   j                  d«      S | j                  j                  |«      x}r|S | j                   j                  d«      r:| j                   d   j                  d«      | j                  |<   | j                  |   S t	        t        «       «      g g dœS )a®  
        Moto does not have a builtin time-series Database, so calling this endpoint will return zero results by default.

        You can use a dedicated API to configuring a queue of expected results.

        An example invocation looks like this:

        .. sourcecode:: python

            first_result = {
                'QueryId': 'some_id',
                'Rows': [...],
                'ColumnInfo': [...],
                'QueryStatus': ...
            }
            result_for_unknown_query_string = {
                'QueryId': 'unknown',
                'Rows': [...],
                'ColumnInfo': [...],
                'QueryStatus': ...
            }
            expected_results = {
                "account_id": "123456789012",  # This is the default - can be omitted
                "region": "us-east-1",  # This is the default - can be omitted
                "results": {
                    # Use the exact querystring, and a list of results for it
                    # For example
                    "SELECT data FROM mytable": [first_result, ...],
                    # Use None if the exact querystring is unknown/irrelevant
                    None: [result_for_unknown_query_string, ...],
                }
            }
            requests.post(
                "http://motoapi.amazonaws.com/moto-api/static/timestream/query-results",
                json=expected_results,
            )

        When calling `query(QueryString='SELECT data FROM mytable')`, the `first_result` will be returned.
        Call the query again for the second result, and so on.

        If you don't know the exact query strings, use the `None`-key. In the above example, when calling `SELECT something FROM unknown`, there are no results for that specific query, so `result_for_unknown_query_string` will be returned.

        Results for unknown queries are cached, so calling `SELECT something FROM unknown` will return the same result.

        r   N)ÚQueryIdÚRowsÚ
ColumnInfo)r@   ÚgetrH   rA   r6   r   )r    r   Úresults      r!   rD   zTimestreamQueryBackend.queryq   sµ   € ð\ ×"Ñ"×&Ñ& |Ô4Ø×*Ñ*¨<Ñ8×<Ñ<¸QÓ?Ð?Ø×'Ñ'×+Ñ+¨LÓ9Ð9ˆ6Ð9ØˆMØ×"Ñ"×&Ñ& tÔ,Ø/3×/FÑ/FÀtÑ/L×/PÑ/PÐQRÓ/SˆD×Ñ˜|Ñ,Ø×%Ñ% lÑ3Ð3Üœu›w›<°À2ÑFÐFr#   c                 ó*   — d| j                   › d�ddœgS )Nzquery.timestream.z.amazonaws.comi   )ÚAddressÚCachePeriodInMinutes)r   r1   s    r!   Údescribe_endpointsz)TimestreamQueryBackend.describe_endpoints¨   s)   € ð /¨t×/?Ñ/?Ð.@ÀÐOØ(,ñð
ð 	
r#   )r3   r4   r5   Ú__doc__r6   r"   r7   r   r8   r   rE   rJ   rL   rN   rD   ÚintrX   Ú__classcell__)rB   s   @r!   r;   r;   ?   sL  ø„ Ù1ð; Cð ;°Sõ ;ðàðð ðð !% S¨# X¡ð	ð
 %)¨¨d°3¸°8©nÐ)<Ñ$=ðð # 3¨ 8™n¨tÑ3ðð -0ðð �4˜˜S˜‘>Ñ" TÑ)ðð ˜$‘Jðð %)¨¨d°3¸°8©nÐ)<Ñ$=ðð 
óð8>¸#ð >À$ó >ð;¸Cð ;ÀNó ;ð
¸#ð Àcð Èdó ð5G #ð 5G¨$¨s°C¨x©.ó 5Gðn
 D¨¨c°3¸±9¨nÑ)=Ñ$>÷ 
r#   r;   ztimestream-query)z	us-east-1z	us-east-2z	us-west-2zeu-central-1z	eu-west-1zap-southeast-2zap-northeast-1)Úadditional_regionsN)rY   Útypingr   Úuuidr   Úmoto.core.base_backendr   r   Úmoto.core.common_modelsr   Úmoto.core.utilsr   Úmoto.utilities.utilsr	   Ú
exceptionsr   r   r;   Útimestreamquery_backendsr9   r#   r!   ú<module>re      sQ   ðÙ Cå Ý ç ;Ý -Ý %Ý .å (ô.
�Yô .
ôbt
˜[ô t
ñn 'ØØòôÑ r#   