o
    l>j                     @  s
  d Z ddlmZ ddlmZ ddlmZmZ ddlZddl	m
Z
 ddlmZmZmZmZ ddlmZ dd	lmZ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  ddl!m"Z"m#Z# ddl$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z, ej-ddZ.ej-ddZ/ej-ddZ0ej-ddZ1ej-ddZ2dZ3edZ4dZ5dZ6G dd de7eZ8G dd de7eZ9e8j:e,j:e8j;e,j;iZ<e9j=e'j=e9j>e'j>e9j?e'j?e9j@e'j@iZAdd d!ZBe.jCe/d"d#eBd$ e.jCe1d%d#eBd$ e.jCe0d&d#eBd$ e.jCe2d'd#eBd$ d d+d,ZDd!d0d1ZEd2d3 ZFd4d5 ZGd"d8d9ZHdd:d#dAdBZId$dGdHZJd%dJdKZKd&dNdOZLd'dRdSZMd(dUdVZNe.OdWdddddXeefd)dgdhZPe.OdiejQddjdkdejQdXdldmdejQdndodpdqdrdddddXeef
d*dsdtZRe.OduejSdve5ddddddXeefd+dwdxZTe.OdyejQdvdjdzdejQdvd{d|dejQd}d~ddejQdXe6ddejQddddejQddddejQdXdddejQdXdddejQddddejQdddddddddXeefd,ddZUe.OdejSdve5dejQdd{d|dejQdd~ddejQde6ddejQddddejQdXdddejQddddejQddddejQddddejQddddejQdXdddejQddddejQdXddddddddXeefd-ddZVe.OdejSdve5dejQd#e6dddddddXeef	d.ddZWe.OdejSdve5ddddddXeefd+ddZXe.OdejQdvdjdkdejQdXdldmdejQdddpddrdddddXeef
d/ddZYe.OdejQddddejQdndodpddrdddddXeef	d0ddZZe.OddddddXeefd)ddZ[e/OdiejSdve5ddddddXeefd+ddÄZ\e/OdġejSdve5dejQdvd{ddejQdvdddejQdvdddejQdvdddejQdddddrejQe8j:ddddddddXeefd1dd؄Z]e1OdiejSdve5ddddddXeefd+ddڄZ^e1OdyejSdve5dejSdvdddddddXeef	d2ddބZ_e1OdejSdve5dejSdvddejQdvddddddddXeef
d3ddZ`e1OdejSdve5dejSdvdddddddXeef	d4ddZae0OdiejSdve5ddddddXeefd+ddZbe0OdejSdve5dejQdvdddejQdddddddddXeef
d5ddZce0OdejSdve5dejSdvddejQddddejQddddejQddddejQdddddrejQdddddrejQdddddrdddddXeefd6ddZde0OdejSdve5dejSdvdddddddXeef	d7ddZee2OdiejSdve5ddddddXeefd+ddZfe2OdyejSdve5dejQe9j=d	d
dejQdpddpddrejQdddddrejQdddddddddddXeefd8ddZge2OdejSdve5dejSdvddejQdd	d
dejQdddpddrejQdddddrejQdddddddddddXeefd9ddZhe2OdejSdve5dejSdvdddddddXeef	d:ddZidS (;  zReminders commands.    )annotations)Enum)CallableTypeVarN)ValidationError)CLIAbort	get_stateparse_datetimeservice_call)normalize_sync_cursor)
DEFAULT_LOG_LEVELDEFAULT_OUTPUT_FORMATHttpProxyOptionHttpsProxyOptionLogLevelOptionNoVerifySslOptionOutputFormatOptionSessionDirOptionUsernameOptionstore_command_options)console_kv_tableconsole_tableformat_color_value)RemindersApiErrorRemindersAuthError)AlarmWithTriggerImageAttachmentRecurrenceFrequencyReminderURLAttachment)
Attachment	ProximityzInspect and mutate Reminders.)helpzWork with reminder alarms.zWork with reminder attachments.zWork with reminder hashtags.z$Work with reminder recurrence rules.	RemindersTRelatedzReminder id.z--completed/--not-completedc                   @  s   e Zd ZdZdZdZdS )ProximityChoicezCLI-facing proximity choice.arrivingleavingN)__name__
__module____qualname____doc__ARRIVINGLEAVING r.   r.   T/home/thesage/.local/lib/python3.10/site-packages/pyicloud/cli/commands/reminders.pyr%   1   s    r%   c                   @  s    e Zd ZdZdZdZdZdZdS )RecurrenceFrequencyChoicez CLI-facing recurrence frequency.dailyweeklymonthlyyearlyN)r(   r)   r*   r+   DAILYWEEKLYMONTHLYYEARLYr.   r.   r.   r/   r0   8   s    r0   ctxtyper.ContextreturnNonec                 C  s$   | j du rt|   t dS )z5Show subgroup help when invoked without a subcommand.N)invoked_subcommandtyperechoget_helpExit)r9   r.   r.   r/   _group_rootM   s   
rB   alarmT)nameinvoke_without_commandcallbackhashtag
attachment
recurrencevaluestrprefixc                 C  s8   t |  }|s
|S | d}||r|S | | S )z5Return an identifier with the expected record prefix./)rK   strip
startswith)rJ   rL   
normalizedtokenr.   r.   r/   _normalize_prefixed_idi   s   

rR   	record_idqueryboolc                 C  sD   t | }|s
dS | |krdS d| v r | ddd |kr dS dS )z=Return whether a record id matches a full or shorthand query.FTrM      )rK   rN   split)rS   rT   rP   r.   r.   r/   _id_matchesu   s   rX   c                   s   t t fdd jdS )z<Return the Reminders service with reauthentication handling.c                     s    j S N	remindersr.   apir.   r/   <lambda>   s    z$_reminders_service.<locals>.<lambda>account_name)r
   	REMINDERSr`   r\   r.   r\   r/   _reminders_service   s   rb   c                 C  sB   z	t t|| jdW S  ttttfy  } ztt||d}~ww )z>Wrap reminder calls with reminder-specific user-facing errors.r_   N)	r
   ra   r`   LookupErrorr   r   r   r   rK   )r]   fnerrr.   r.   r/   _reminders_call   s   rf   reminder_idr   c                   s   t | t|  fddS )zReturn one reminder by id.c                     
     S rY   )getr.   rg   r[   r.   r/   r^         
 z#_resolve_reminder.<locals>.<lambda>)rb   rf   )r]   rg   r.   rj   r/   _resolve_reminder   s   rl   )list_idrm   
str | Noneinclude_completedlimitintlist[Reminder]c          	        s   t | t|drt|  fdd}|jd| S g }t }t| fddD ]3}t| |jf fdd	}|jD ]}|j|v rGq?||j || t||kr^|    S q?q,|S )zOReturn reminder rows using compound snapshots to preserve completion filtering.   c                        j td dS NListrm   ro   results_limitlist_remindersrR   r.   ro   rm   r[   rx   r.   r/   r^      
    z%_list_reminder_rows.<locals>.<lambda>Nc                        t   S rY   listlistsr.   rZ   r.   r/   r^          c                   s   j |  dS )Nrw   )rz   )lid)ro   r[   rx   r.   r/   r^      s
    )	rb   maxrf   r[   setidaddappendlen)	r]   rm   ro   rp   snapshotrowsseen_idsreminder_listreminderr.   r{   r/   _list_reminder_rows   s2   	



r   label
fetch_rows$Callable[[Reminder], list[TRelated]]tuple[Reminder, TRelated]c                  sh   t | |t|  fdd}|D ]}t|dd}t||r$|f  S qtd| d| dj d)	zAReturn one reminder child record matched by full or shorthand id.c                     s    S rY   r.   r.   r   r   r.   r/   r^          z)_resolve_related_record.<locals>.<lambda>r    zNo z
 matched 'z' for reminder .)rl   rf   getattrrX   r   r   )r]   rg   rT   r   r   r   rowrow_idr.   r   r/   _resolve_related_record   s   


r   r    c                 C  s*   t | trdS t | trdS t| j S )z'Return a compact attachment type label.urlimage)
isinstancer   r   typer(   lower)rH   r.   r.   r/   _attachment_kind   s
   

r   	proximityProximity | Nonec                 C     | du rdS | j  S )z(Return a human-readable proximity label.NrD   r   )r   r.   r.   r/   _proximity_label      
r   	frequencyRecurrenceFrequency | Nonec                 C  r   )z3Return a human-readable recurrence frequency label.Nr   )r   r.   r.   r/   _frequency_label   r   r   cursorc                 C  s(   | j r| t| dS | j| dS )z*Render a sync cursor in JSON or text mode.N)json_output
write_jsonr   consoleprint)stater   r.   r.   r/   _sync_cursor_payload   s   r   r   Fusernamer   session_dirr   
http_proxyr   https_proxyr   no_verify_sslr   output_formatr   	log_levelr   c              
     s|   t | |||||||d t| }| }	t|	 t|	 fdd}
|jr+||
 dS |jt	dg ddd |
D  dS )	zList reminder lists.r   r   r   r   r   r   r   c                     r}   rY   r~   r.   rZ   r.   r/   r^     r   z!reminders_lists.<locals>.<lambda>NzReminder Lists)IDTitleColorCountc                 S  s$   g | ]}|j |jt|j|jfqS r.   )r   titler   colorcount.0r   r.   r.   r/   
<listcomp>   s    z#reminders_lists.<locals>.<listcomp>
r   r   get_apirb   rf   r   r   r   r   r   )r9   r   r   r   r   r   r   r   r   r]   payloadr.   rZ   r/   reminders_lists   s4   

r   r   z	--list-idzReminder list id.z--include-completedzInclude completed reminders.2   z--limitrV   zMaximum reminders to show.)minr"   c              
   C  sr   t | ||||||	|
d t| }| }t||||d}|jr&|| dS |jtdg ddd |D  dS )zList reminders.r   )rm   ro   rp   Nr#   r   r   	CompletedDuePriorityc                 S  $   g | ]}|j |j|j|j|jfqS r.   r   r   	completeddue_datepriorityr   r   r.   r.   r/   r   Z      z"reminders_list.<locals>.<listcomp>)	r   r   r   r   r   r   r   r   r   )r9   rm   ro   rp   r   r   r   r   r   r   r   r   r]   r   r.   r.   r/   reminders_list-  s<   

r   ri   .c	                 C  s   t | |||||||d t| }	|	 }
t|
|}|	jr#|	| dS |	jtd|j	 d|j
fd|jfd|jfd|jfd|jfd	|jfd
|jfd|jfd|jfd|jfg
 dS )zGet one reminder.r   Nz
Reminder: r   List IDDescriptionr   zDue Dater   FlaggedzAll Dayz	Time ZonezParent Reminder)r   r   r   rl   r   r   r   r   r   r   r   rm   descr   r   r   flaggedall_day	time_zoneparent_reminder_id)r9   rg   r   r   r   r   r   r   r   r   r]   r   r.   r.   r/   reminders_geth  s@   



r   createzTarget list id.z--titlezReminder title.r   z--desczReminder description.z/Create the reminder as completed or incomplete.z
--due-datezDue datetime.z
--priorityzApple priority number.z--flagged/--not-flaggedz)Create the reminder flagged or unflagged.z--all-day/--not-all-dayz(Create the reminder as all-day or timed.z--time-zonezIANA time zone.z--parent-reminder-idz!Parent reminder id for a subtask.r   r   r   r   r   r   r   r   r   c                   s|   t | |||||||d t| }| }t|t| 	
fdd}|jr5|| dS |j|j	 dS )zCreate a reminder.r   c                     s(   j td
t 	d
S )Nrv   )
rm   r   r   r   r   r   r   r   r   r   )r   rR   r	   r.   r   r   r   r   r   rm   r   r   r[   r   r   r.   r/   r^     s    z"reminders_create.<locals>.<lambda>N)
r   r   r   rb   rf   r   r   r   r   r   )r9   rm   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r]   r   r.   r   r/   reminders_create  s*   '

r   updatez*Mark the reminder completed or incomplete.z--clear-due-datezClear the due date.zApple priority.zFlag or unflag the reminder.zMark as all-day or timed.z--clear-time-zonezClear the time zone.zSet the parent reminder id.z--clear-parent-reminderzClear the parent reminder id.bool | Noneclear_due_date
int | Noneclear_time_zoneclear_parent_reminderc              
     s  |r	|r	t d|
r|rt d|r|rt dt| |||||||d t| }| }t|t|| d}|durC| _d}|durL| _d}|durU| _	d}|durat
| _d}n|rhd _d}|durq| _d}|durz| _d}|	dur|	 _d}|
dur|
 _d}n|rd _d}|dur| _d}n|rd _d}|stdt| fd	d
 |jr|  dS |jd j  dS )zUpdate one reminder.z7Choose either --due-date or --clear-due-date, not both.z9Choose either --time-zone or --clear-time-zone, not both.zHChoose either --parent-reminder-id or --clear-parent-reminder, not both.r   FNTz#No reminder updates were requested.c                     rh   rY   r   r.   r   r[   r.   r/   r^   ]  rk   z"reminders_update.<locals>.<lambda>Updated )r>   BadParameterr   r   r   rb   rl   r   r   r   r	   r   r   r   r   r   r   r   rf   r   r   r   r   r   )r9   rg   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r]   changedr.   r   r/   reminders_update  s   6



r   z
set-statusc
              
     s   t | |||||||	d t| }
|
 }t|t|| | _t| fdd |
jr4|
  dS |
j	
d j d|  dS )z(Mark a reminder completed or incomplete.r   c                     rh   rY   r   r.   r   r.   r/   r^     rk   z&reminders_set_status.<locals>.<lambda>Nr   z: completed=)r   r   r   rb   rl   r   rf   r   r   r   r   r   )r9   rg   r   r   r   r   r   r   r   r   r   r]   r.   r   r/   reminders_set_statusd  s(   


r   deletec	              
     s   t | |||||||d t| }	|	 }
t|
t|
| t|
 fdd |	jr5|	 jdd dS |	j	
d j  dS )zDelete a reminder.r   c                     rh   rY   )r   r.   r   r.   r/   r^     rk   z"reminders_delete.<locals>.<lambda>T)rg   deletedNDeleted )r   r   r   rb   rl   rf   r   r   r   r   r   )r9   rg   r   r   r   r   r   r   r   r   r]   r.   r   r/   reminders_delete  s&   

r   r   rs   z--results-limitz5Maximum reminders to request from the compound query.rx   c                   s   t | ||||||	|
d t| }| }t|t| fdd}|jr.|| dS |jt	ddt
dfdt|jfd	t|jfd
t|jfdt|jfdt|jfdt|jfg |jtdg ddd |jD  dS )z0Fetch a compound reminder snapshot for one list.r   c                     rt   ru   ry   r.   r{   r.   r/   r^     r|   z$reminders_snapshot.<locals>.<lambda>NzReminder Snapshotr   rv   r#   AlarmsTriggersAttachmentsHashtagszRecurrence RuleszSnapshot Remindersr   c                 S  r   r.   r   r   r.   r.   r/   r     r   z&reminders_snapshot.<locals>.<listcomp>)r   r   r   rb   rf   r   r   r   r   r   rR   r   r[   alarmstriggersattachmentshashtagsrecurrence_rulesr   )r9   rm   ro   rx   r   r   r   r   r   r   r   r   r]   r   r.   r{   r/   reminders_snapshot  sT   

r   changesz--sincezSync cursor.zMaximum changes to show.sincec
              
     s   t | |||||||	d t| }
|
 }t|t| fdd}|
jr-|
| dS |
jt	dg ddd |D  dS )	z%List reminder changes since a cursor.r   c                     s   t jdd   S )N)r   )r   iter_changesr.   rp   r[   r   r.   r/   r^     s    z#reminders_changes.<locals>.<lambda>NzReminder Changes)TypeReminder IDr   r   c                 S  s8   g | ]}|j |j|jr|jjnd |jr|jjnd fqS rY   )r   rg   r   r   r   )r   eventr.   r.   r/   r   (  s    z%reminders_changes.<locals>.<listcomp>r   )r9   r   rp   r   r   r   r   r   r   r   r   r]   r   r.   r   r/   reminders_changes  s:   

r  zsync-cursorc              
     sP   t | |||||||d t| }| }	t|	 t|	 fdd}
t||
 dS )z(Print the current Reminders sync cursor.r   c                     s      S rY   )sync_cursorr.   rZ   r.   r/   r^   O  r   z'reminders_sync_cursor.<locals>.<lambda>N)r   r   r   rb   rf   r   )r9   r   r   r   r   r   r   r   r   r]   r   r.   rZ   r/   reminders_sync_cursor5  s   
r  c	              
        t | |||||||d t| }	|	 }
t|
t|
| t|
 fdd}|	jr1|	| dS |	j	t
dg ddd |D  dS )	zList alarms for one reminder.r   c                     rh   rY   )
alarms_forr.   r   r.   r/   r^   o  rk   z&reminders_alarm_list.<locals>.<lambda>NzReminder Alarms)zAlarm IDz
Trigger IDr   AddressRadiusr!   c              	   S  sj   g | ]1}|j j|jr|jjnd |jr|jjnd |jr|jjnd |jr&|jjnd t|jr/|jjnd fqS rY   )rC   r   triggerr   addressradiusr   r   r   r.   r.   r/   r   ~  s    	z(reminders_alarm_list.<locals>.<listcomp>r   r   r   rb   rl   rf   r   r   r   r   r   r9   rg   r   r   r   r   r   r   r   r   r]   r   r.   r   r/   reminders_alarm_listS  s6   


	r  zadd-locationzLocation title.z	--addresszLocation address.z
--latitudezLocation latitude.z--longitudezLocation longitude.g      Y@z--radiusg        zRadius in meters.z--proximityzTrigger direction.r  latitudefloat	longituder  c              
     s   t | ||	|
||||d t| }| }t|t||t| fdd\}}t||d}|jr?|| dS |j	
d|j d|j  dS )z#Add a location alarm to a reminder.r   c                	     s   j  t dS )N)r   r  r  r  r  r   )add_location_triggerPROXIMITY_MAPr.   r  r  r  r   r  r   r[   r   r.   r/   r^     s    z.reminders_alarm_add_location.<locals>.<lambda>)rC   r
  NzCreated z with trigger )r   r   r   rb   rl   rf   r   r   r   r   r   r   )r9   rg   r   r  r  r  r  r   r   r   r   r   r   r   r   r   r]   rC   r
  r   r.   r  r/   reminders_alarm_add_location  s.   


 r  c	              
     r  )	zList hashtags for one reminder.r   c                     rh   rY   tags_forr.   r   r.   r/   r^     rk   z(reminders_hashtag_list.<locals>.<lambda>NzReminder Hashtags)r   Namer  c                 S  s   g | ]
}|j |j|jfqS r.   )r   rD   rg   r   r.   r.   r/   r     s    z*reminders_hashtag_list.<locals>.<listcomp>r  r  r.   r   r/   reminders_hashtag_list  s2   


r  zHashtag name.rD   c
              
     sv   t | |||||||	d t| }
|
 }t|t||t| fdd}|
jr2|
| dS |
j	|j
 dS )z!Create a hashtag on one reminder.r   c                          S rY   )create_hashtagr.   rD   r   r[   r.   r/   r^     r   z*reminders_hashtag_create.<locals>.<lambda>Nr   r   r   rb   rl   rf   r   r   r   r   r   )r9   rg   rD   r   r   r   r   r   r   r   r   r]   r   r.   r  r/   reminders_hashtag_create  s&   


r  zHashtag id.z--namezUpdated hashtag name.
hashtag_idc              
     s   t | ||||||	|
d t| }| }t|t|||dfddd\} t| fdd  _|jr?|  dS |j	
d j  dS )	zUpdate a hashtag name.r   rG   c                   
     | S rY   r  r   rZ   r.   r/   r^   5  rk   z*reminders_hashtag_update.<locals>.<lambda>r   r   c                     s     S rY   )update_hashtagr.   rG   rD   r[   r.   r/   r^   7  r   Nr   )r   r   r   rb   r   rf   rD   r   r   r   r   r   )r9   rg   r   rD   r   r   r   r   r   r   r   r   r]   	_reminderr.   r%  r/   reminders_hashtag_update  s4   



r'  c
              
        t | |||||||	d t| }
|
 }t|t|||dfddd\ t| fdd j jdd}|
jrD|
| d	S |
j	
d
 j  d	S )z#Delete a hashtag from one reminder.r   rG   c                   r!  rY   r  r   rZ   r.   r/   r^   `  rk   z*reminders_hashtag_delete.<locals>.<lambda>r#  c                     r  rY   )delete_hashtagr.   rG   r   r[   r.   r/   r^   b  r   T)rg   r   r   Nr   r   r   r   rb   r   rf   r   r   r   r   r   )r9   rg   r   r   r   r   r   r   r   r   r   r]   r   r.   r+  r/   reminders_hashtag_delete?  s4   



r-  c	              
     r  )	z"List attachments for one reminder.r   c                     rh   rY   attachments_forr.   r   r.   r/   r^     rk   z+reminders_attachment_list.<locals>.<lambda>NzReminder Attachments)r   r   URLFilenameUTISizec                 S  s<   g | ]}|j t|t|d dt|dd|jt|ddfqS )r   Nfilename	file_size)r   r   r   utir   r.   r.   r/   r     s    	


z-reminders_attachment_list.<locals>.<listcomp>r  r  r.   r   r/   reminders_attachment_listj  s6   


	r7  z
create-urlz--urlzAttachment URL.z
public.urlz--utizAttachment UTI.r   r6  c              
     sx   t | ||||||	|
d t| }| }t|t|| t| fdd}|jr3|| dS |j	|j
 dS )z(Create a URL attachment on one reminder.r   c                     s   j  dS )N)r   r6  )create_url_attachmentr.   r   r[   r   r6  r.   r/   r^     s    z1reminders_attachment_create_url.<locals>.<lambda>Nr  )r9   rg   r   r6  r   r   r   r   r   r   r   r   r]   r   r.   r9  r/   reminders_attachment_create_url  s,   


r:  zAttachment id.zUpdated attachment URL.zUpdated attachment UTI.z
--filenamezUpdated attachment filename.z--file-sizezUpdated attachment size.z--widthzUpdated attachment width.z--heightzUpdated attachment height.attachment_idr4  r5  widthheightc              
     sF  t dd fD rtdt| |	|
|||||d t| }| }t|t|||dfddd\} t| fd	d d
urVt drV _	d
ur] _
d
urit dri _d
urut dru _d
urt dr _d
urt dr _|jr|  d
S |jd j  d
S )zUpdate one attachment.c                 s      | ]}|d u V  qd S rY   r.   r   rJ   r.   r.   r/   	<genexpr>  s    z.reminders_attachment_update.<locals>.<genexpr>z%No attachment updates were requested.r   rH   c                   r!  rY   r.  r"  rZ   r.   r/   r^     rk   z-reminders_attachment_update.<locals>.<lambda>r#  c                	     s   j  dS )N)r   r6  r4  r5  r<  r=  )update_attachmentr.   rH   r5  r4  r=  r[   r   r6  r<  r.   r/   r^     s    Nr   r4  r5  r<  r=  r   )allr   r   r   r   rb   r   rf   hasattrr   r6  r4  r5  r<  r=  r   r   r   r   r   )r9   rg   r;  r   r6  r4  r5  r<  r=  r   r   r   r   r   r   r   r   r]   r&  r.   rB  r/   reminders_attachment_update  sT   (



rE  c
              
     r(  )zDelete one attachment.r   rH   c                   r!  rY   r.  r)  rZ   r.   r/   r^   C  rk   z-reminders_attachment_delete.<locals>.<lambda>r#  c                     r  rY   )delete_attachmentr.   rH   r   r[   r.   r/   r^   E  r   T)rg   r;  r   Nr   r,  )r9   rg   r;  r   r   r   r   r   r   r   r   r]   r   r.   rG  r/   reminders_attachment_delete"  s:   



rH  c	              
     r  )	z'List recurrence rules for one reminder.r   c                     rh   rY   recurrence_rules_forr.   r   r.   r/   r^   m  rk   z+reminders_recurrence_list.<locals>.<lambda>NzReminder Recurrence Rules)r   	FrequencyIntervalzOccurrence Countz	First Dayc                 S  s(   g | ]}|j t|j|j|j|jfqS r.   )r   r   r   intervaloccurrence_countfirst_day_of_weekr   r.   r.   r/   r   u  s    z-reminders_recurrence_list.<locals>.<listcomp>r  r  r.   r   r/   reminders_recurrence_listQ  s6   


rP  z--frequencyzRecurrence frequency.z
--intervalzRecurrence interval.z--occurrence-countz$Occurrence count; 0 means unlimited.z--first-day-of-week   zFirst day of week; 0 is Sunday.)r   r   r"   rM  rN  rO  c              
     s|   t | ||||	|
||d t| }| }t|t||t| fdd}|jr5|| dS |j	|j
 dS )z)Create a recurrence rule on one reminder.r   c                     s   j t  dS N)r   rM  rN  rO  )create_recurrence_ruleRECURRENCE_FREQUENCY_MAPr.   rO  r   rM  rN  r   r[   r.   r/   r^     s    z-reminders_recurrence_create.<locals>.<lambda>Nr  )r9   rg   r   rM  rN  rO  r   r   r   r   r   r   r   r   r]   r   r.   rU  r/   reminders_recurrence_create  s,   !



rV  zRecurrence rule id.rule_id RecurrenceFrequencyChoice | Nonec              
     s   t dd  fD rtdt| |||	|
|||d t| }| }t|t|||dfddd\}t| fd	d d
urOt _	d
urV_
d
ur]_ d
urd _|jrn| d
S |jdj  d
S )zUpdate one recurrence rule.c                 s  r>  rY   r.   r?  r.   r.   r/   r@    s
    
z.reminders_recurrence_update.<locals>.<genexpr>z%No recurrence updates were requested.r   recurrence rulec                   r!  rY   rI  r"  rZ   r.   r/   r^     rk   z-reminders_recurrence_update.<locals>.<lambda>r#  c                     s$   j d urt nd  dS rR  )update_recurrence_rulerT  r.   rO  r   rM  rN  recurrence_ruler[   r.   r/   r^     s    Nr   )rC  r   r   r   r   rb   r   rf   rT  r   rM  rN  rO  r   r   r   r   r   )r9   rg   rW  r   rM  rN  rO  r   r   r   r   r   r   r   r   r]   r&  r.   r[  r/   reminders_recurrence_update  sP   '





r]  c
              
     r(  )zDelete one recurrence rule.r   rY  c                   r!  rY   rI  r)  rZ   r.   r/   r^   >  rk   z-reminders_recurrence_delete.<locals>.<lambda>r#  c                     r  rY   )delete_recurrence_ruler.   r\  r   r[   r.   r/   r^   B  r   T)rg   recurrence_rule_idr   Nr   r,  )r9   rg   rW  r   r   r   r   r   r   r   r   r]   r   r.   r_  r/   reminders_recurrence_delete  s@   



ra  )r9   r:   r;   r<   )rJ   rK   rL   rK   r;   rK   )rS   rK   rT   rK   r;   rU   )rg   rK   r;   r   )rm   rn   ro   rU   rp   rq   r;   rr   )
rg   rK   rT   rK   r   rK   r   r   r;   r   )rH   r    r;   rK   )r   r   r;   rn   )r   r   r;   rn   )r   rK   r;   r<   )r9   r:   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rm   rn   ro   rU   rp   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rg   rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )&r9   r:   rm   rK   r   rK   r   rK   r   rU   r   rn   r   rq   r   rU   r   rU   r   rn   r   rn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   ),r9   r:   rg   rK   r   rn   r   rn   r   r   r   rn   r   rU   r   r   r   r   r   r   r   rn   r   rU   r   rn   r   rU   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rg   rK   r   rU   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rm   rK   ro   rU   rx   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   r   rn   rp   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   ) r9   r:   rg   rK   r   rK   r  rK   r  r  r  r  r  r  r   r%   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rg   rK   rD   rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rg   rK   r   rK   rD   rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rg   rK   r   rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rg   rK   r   rK   r6  rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )"r9   r:   rg   rK   r;  rK   r   rn   r6  rn   r4  rn   r5  r   r<  r   r=  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rg   rK   r;  rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rg   rK   r   r0   rM  rq   rN  rq   rO  rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rg   rK   rW  rK   r   rX  rM  r   rN  r   rO  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )r9   r:   rg   rK   rW  rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r<   )jr+   
__future__r   enumr   typingr   r   r>   pydanticr   pyicloud.cli.contextr   r   r	   r
   pyicloud.cli.normalizer   pyicloud.cli.optionsr   r   r   r   r   r   r   r   r   r   pyicloud.cli.outputr   r   r   "pyicloud.services.reminders.clientr   r   "pyicloud.services.reminders.modelsr   r   r   r   r   #pyicloud.services.reminders.servicer    r!   Typerapp	alarm_appattachment_apphashtag_apprecurrence_appra   r$   _REMINDER_ID_HELP_COMPLETED_OPTION_PARAMrK   r%   r0   r,   r-   r  r5   r6   r7   r8   rT  rB   	add_typerrR   rX   rb   rf   rl   r   r   r   r   r   r   commandr   Optionr   Argumentr   r   r   r   r   r   r  r  r  r  r  r  r'  r-  r7  r:  rE  rH  rP  rV  r]  ra  r.   r.   r.   r/   <module>   s   0

+
	.:0H ("P398(#+*2'\.1>Z