
    Dj                        d Z ddlmZ ddlZddlmZmZmZmZ ddl	m
Z
mZmZmZmZmZmZmZmZ ddlmZmZmZmZ  ej        e          Z G d de          Z G d	 d
e          Z G d d          ZdS )z8
Low-level CloudKit client for the Reminders container.
    )annotationsN)DictListNoReturnOptional)	CKLookupResponseCKModifyOperationCKModifyResponseCKQueryObjectCKQueryResponseCKZoneChangesResponseCKZoneChangesZoneReqCKZoneIDReqCloudKitExtraMode)CloudKitApiErrorCloudKitAuthErrorCloudKitContainerClientCloudKitRateLimitedc                      e Zd ZdZdS )RemindersAuthErrorz!Auth/PCS/cookie issues (401/403).N)__name__
__module____qualname____doc__     ]/home/thesage/.hermes/venv/lib/python3.11/site-packages/pyicloud/services/reminders/client.pyr   r      s        ++++r   r   c                  &     e Zd ZdZdd	 fdZ xZS )
RemindersApiErrorzCatch-all API error.NmessagestrpayloadOptional[object]c                X    t                                          |           || _        d S N)super__init__r"   )selfr    r"   	__class__s      r   r'   zRemindersApiError.__init__&   s&    !!!r   r%   )r    r!   r"   r#   )r   r   r   r   r'   __classcell__)r)   s   @r   r   r   #   sH                  r   r   c                      e Zd ZdZddd5d
Zed6d            Zd7dZddddd8d Zd!d"d9d%Z	dd&d:d*Z
dd+d;d1Zd<d4ZdS )=CloudKitRemindersClientz;
    Raw CloudKit service for the Reminders container.
    N)validation_extrabase_urlr!   base_paramsDict[str, object]r-   CloudKitExtraMode | Nonec               H    t          ||||dd          | _        || _        d S )NlowerF)r-   bool_param_stylehandle_rate_limits)r   _client_validation_extra)r(   r.   sessionr/   r-   s        r   r'   z CloudKitRemindersClient.__init__0   s<     /-$$
 
 
 "2r   exc	Exceptionreturnr   c                b   | j         p| }t          | t                    rt          t	          |                     |t          | t
                    r&t          t	          |           d| j        i          |t          | t                    r$t          t	          |           | j	                  | )Nretry_after)r"   )
	__cause__
isinstancer   r   r!   r   r   r=   r   r"   )r9   causes     r   _raise_reminders_errorz.CloudKitRemindersClient._raise_reminders_errorB   s    $c,-- 	:$SXX..E9c.// 	#C=#/"B   c+,, 	N#CHHckBBBMr   record_names	List[str]zone_idr   r   c                    	 | j                             ||          S # t          t          t          f$ r }|                     |           Y d}~dS d}~ww xY w)zFetch records by ID.)rD   N)r6   lookupr   r   r   rA   )r(   rB   rD   r9   s       r   rF   zCloudKitRemindersClient.lookupO   sp    	-<&&|W&EEE "35HI 	- 	- 	-'',,,,,,,,,	-    AAA)desired_keysresults_limitcontinuationqueryr   rH   Optional[List[str]]rI   Optional[int]rJ   Optional[str]r   c                   	 | j                             |||||          S # t          t          t          f$ r }|                     |           Y d }~d S d }~ww xY w)N)rK   rD   rH   rI   rJ   )r6   rK   r   r   r   rA   )r(   rK   rD   rH   rI   rJ   r9   s          r   rK   zCloudKitRemindersClient.queryZ   s    		-<%%)+) &    !"35HI 	- 	- 	-'',,,,,,,,,	-s   ! AAAreminderList)record_typerQ   
str | Nonec                  	 | j                             t          |          |          S # t          $ r }|                     |           Y d}~dS d}~wt
          t          f$ r'}t                              d|           Y d}~dS d}~ww xY w)zBFetch the current zone sync token using a lightweight query first.)
recordType)rK   rD   Nz,current_sync_token suppressed CloudKit error)exc_info)	r6   query_sync_tokenr   r   rA   r   r   LOGGERdebug)r(   rD   rQ   r9   s       r   current_sync_tokenz*CloudKitRemindersClient.current_sync_tokenn   s    		<00#{;;; 1    ! 	- 	- 	-'',,,,,,,,, "56 	 	 	LLGRULVVV44444	s    ), 
BAB%BB)rI   zone_reqr   r   c                   	 | j                             ||          S # t          t          t          f$ r }|                     |           Y d}~dS d}~ww xY w)z Fetch changes (sync) for a zone.)rZ   rI   N)r6   changesr   r   r   rA   )r(   rZ   rI   r9   s       r   r\   zCloudKitRemindersClient.changes   s|    	-<''!+ (    !"35HI 	- 	- 	-'',,,,,,,,,	-rG   )atomic
operationsList[CKModifyOperation]r]   Optional[bool]r
   c                   	 | j                             |||          S # t          t          t          f$ r }|                     |           Y d}~dS d}~ww xY w)z&Modify (create/update/delete) records.)r^   rD   r]   N)r6   modifyr   r   r   rA   )r(   r^   rD   r]   r9   s        r   rb   zCloudKitRemindersClient.modify   s    	-<&&% '   
 !"35HI 	- 	- 	-'',,,,,,,,,	-s    AAAurlbytesc                    	 | j                             |          S # t          t          t          f$ r }|                     |           Y d}~dS d}~ww xY w)z-Download raw bytes from a CloudKit asset URL.N)r6   download_asset_bytesr   r   r   rA   )r(   rc   r9   s      r   rf   z,CloudKitRemindersClient.download_asset_bytes   sk    	-<44S999 "35HI 	- 	- 	-'',,,,,,,,,	-s    AAA)r.   r!   r/   r0   r-   r1   )r9   r:   r;   r   )rB   rC   rD   r   r;   r   )rK   r   rD   r   rH   rL   rI   rM   rJ   rN   r;   r   )rD   r   rQ   r!   r;   rR   )rZ   r   rI   rM   r;   r   )r^   r_   rD   r   r]   r`   r;   r
   )rc   r!   r;   rd   )r   r   r   r   r'   staticmethodrA   rF   rK   rY   r\   rb   rf   r   r   r   r,   r,   +   s         6:2 2 2 2 2 2$ 
 
 
 \
	- 	- 	- 	-  -1'+&*- - - - - -0 *	     , (,	- - - - - -( "&- - - - - -"- - - - - -r   r,   )r   
__future__r   loggingtypingr   r   r   r   pyicloud.common.cloudkitr   r	   r
   r   r   r   r   r   r   pyicloud.common.cloudkit.clientr   r   r   r   	getLoggerr   rW   r:   r   r   r,   r   r   r   <module>rn      s    # " " " " "  1 1 1 1 1 1 1 1 1 1 1 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
            
	8	$	$, , , , , , , ,    	   z- z- z- z- z- z- z- z- z- z-r   