
    3fi                         d dl Z d dlmZmZ d dlmZ ddlmZmZmZ  e j                  e
      Z G d de      Z G d d	e      Z G d
 de      Z G d de      Z G d de      Z G d de      Zy)    N)datedatetime)parse   )NEXT_LINK_KEYWORDApiComponent
Paginationc                   F     e Zd ZddiZddd fd
Zd Zd Zd Zd	 Z xZ	S )
TaskDetailstask_detail/planner/tasks/{id}/detailsNparentconc                   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  |d      }t        | %  |r|j                  n|j                  d      |       |j                  | j                  d	      d      | _        |j                  | j                  d
      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  dd      | _        y)aj  A Microsoft 365 plan details

        :param parent: parent object
        :type parent: Task
        :param Connection con: connection to use if no parent specified
        :param Protocol protocol: protocol to use if no parent specified
         (kwargs)
        :param str main_resource: use this resource instead of parent resource
         (kwargs)
        *Need a parent or a connection but not bothidmain_resourceN{}{} protocolr   r   description
references	checklistpreviewType@odata.etag)
ValueErrorr   get_cloud_data_key	object_idpopgetattrformatsuper__init__r   _ccr   r   r   preview_type_etagselfr   r   kwargs
cloud_datar   	__class__s         J/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/O365/planner.pyr&   zTaskDetails.__init__   s6    cIJJ!'6::SZZ 4 4b9
 $- 

?D9 
6<GFOT2$ 	 mR8(.V__FJJz4J' 	 	
 &>>$((=*A2F$..,)?D#(=rB
 'NN488M+BBG^^M26
    c                 "    | j                         S N__repr__r+   s    r/   __str__zTaskDetails.__str__<       }}r0   c                      y)NzTask Details r5   s    r/   r4   zTaskDetails.__repr__?       r0   c                 4    | j                   |j                   k(  S r2   r!   r+   others     r/   __eq__zTaskDetails.__eq__B       ~~00r0   c                    | j                   syd}| j                  | j                  j                  d      j	                  | j                               }|j                         D ci c]  \  }}|dv r| j                  |      | }}}|syd|v rt        |d   t              rt        |d   j                               D ]  t        |d      t              rd|d      vrd|d      d<   t        fd	|D              sCd
j                  j                  dd      D cg c]2  }||j                  dd      vrt        |      ndj	                  |      4 c}      }|d   j                        |d   |<    d|v rE|d   j                         D ]/  t        |d      t              sd|d      vs%d|d      d<   1 | j                   j#                  ||| j$                  dd      }	|	sy|	j'                         }
|D ]=  |
j                  d      }|t)        | | j*                  j-                        |       ? |
j                  d      | _        yc c}}w c c}w )a+  Updates this task detail

        :param kwargs: all the properties to be updated.
        :param dict checklist: the collection of checklist items on the task.

        .. code-block::

            e.g. checklist = {
              "string GUID": {
                "isChecked": bool,
                "orderHint": string,
                "title": string
              }
            } (kwargs)

        :param str description: description of the task
        :param str preview_type: this sets the type of preview that shows up on the task.

            The possible values are: automatic, noPreview, checklist, description, reference.

        :param dict references: the collection of references on the task.

        .. code-block::

            e.g. references = {
              "URL of the resource" : {
                "alias": string,
                "previewPriority": string, #same as orderHint
                "type": string, #e.g. PowerPoint, Excel, Word, Pdf...
              }
            }

        :return: Success / Failure
        :rtype: bool
        Fz.:@#r   r   )r   r   r(   r   r   @odata.typez)#microsoft.graph.plannerExternalReferencec              3   &   K   | ]  }|v  
 y wr2   r9   ).0ukeys     r/   	<genexpr>z%TaskDetails.update.<locals>.<genexpr>   s     1AqCx1s   r   zutf-8strictz%{:02X}r   z%#microsoft.graph.plannerChecklistItemreturn=representationIf-MatchPreferdataheadersNr   T)r!   	build_url
_endpointsr   r$   itemsr'   
isinstancedictlistkeysanyjoinencodechrr"   r   patchr)   jsonsetattrr   to_api_case)r+   r,   _unsafeurlrG   valuerO   bsanitized_keyresponsenew_datas       `      r/   updatezTaskDetails.updateE   s   H ~~nnOO.555H
 %lln

U HHSM5 

 

 4JtL/A4$HD.3356 TtL1#6=)T,-?-DD D &s+M: 111$&GG
 &)ZZ%B	 !"  !w(II  F!*!1!1!!45%M 9=\8J8N8Ns8SD&}5%T( $K(--/ tK05t<)T+->s-CC @ %c*=9 88>>!%7NO " 

 ==? 	ECLLd+E dmm77<eD	E
 \\-0
}

4s   ( I#7I#

__name__
__module____qualname__rR   r&   r6   r4   r?   rg   __classcell__r.   s   @r/   r   r      s.    !>?J!%4 ,7\1kr0   r   c                   F     e Zd ZddiZddd fd
Zd Zd Zd Zd	 Z xZ	S )
PlanDetailsplan_detail/planner/plans/{id}/detailsNr   c                B   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  |d      }t        | %  |r|j                  n|j                  d      |       |j                  | j                  d	      d      | _        |j                  | j                  d
      d      | _        |j                  dd      | _        y)aj  A Microsoft 365 plan details

        :param parent: parent object
        :type parent: Plan
        :param Connection con: connection to use if no parent specified
        :param Protocol protocol: protocol to use if no parent specified
         (kwargs)
        :param str main_resource: use this resource instead of parent resource
         (kwargs)
        r   r   r   Nr   r   r   r   
sharedWithcategoryDescriptionsr   )r   r   r   r    r!   r"   r#   r$   r%   r&   r   r'   shared_withcategory_descriptionsr)   r*   s         r/   r&   zPlanDetails.__init__   s    cIJJ!'6::SZZ 4 4b9
 $- 

?D9 
6<GFOT2$ 	 mR8(.V__FJJz4J' 	 	
 &>>$((<*@"E &0^^HH+,b&
"  ^^M26
r0   c                 "    | j                         S r2   r3   r5   s    r/   r6   zPlanDetails.__str__   r7   r0   c                      y)NzPlan Detailsr9   r5   s    r/   r4   zPlanDetails.__repr__   r:   r0   c                 4    | j                   |j                   k(  S r2   r<   r=   s     r/   r?   zPlanDetails.__eq__   r@   r0   c                 P   | j                   sy| j                  | j                  j                  d      j	                  | j                               }|j                         D ci c]  \  }}|dv r| j                  |      | }}}|sy| j                  j                  ||| j                  dd      }|sy|j                         }|D ]=  }|j                  |d      }|t        | | j                  j                  |      |       ? |j                  d	      | _	        y
c c}}w )a  Updates this plan detail

        :param kwargs: all the properties to be updated.
        :param dict shared_with: dict where keys are user_ids and values are boolean (kwargs)
        :param dict category_descriptions: dict where keys are category1, category2, ..., category25 and values are the label associated with (kwargs)
        :return: Success / Failure
        :rtype: bool
        Frp   rB   )ru   rv   rJ   rK   rN   Nr   Tr!   rQ   rR   r   r$   rS   r'   r   r\   r)   r]   r^   r   r_   r+   r,   ra   rG   rb   rO   re   rf   s           r/   rg   zPlanDetails.update   s     ~~nnOO.555H
 %lln
U>> HHSM5 
 

 88>>!%7NO " 

 ==? 	ECLLd+E dmm77<eD	E
 \\-0
3
   % D"rh   rm   s   @r/   ro   ro      s-    !>?J!%4 (7T1)r0   ro   c                   \     e Zd ZdZdddZeZddd fd
Zd Zd	 Z	d
 Z
d Zd Zd Z xZS )TaskzA Microsoft Planner taskr   z/planner/tasks/{id})get_detailstaskNr   c                *   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  |d      }t        | %  |r|j                  n|j                  d      |       |j                  d	      | _        |j                  d
      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      }|j                  | j                  d      d      }|j                  | j                  d      d      }|j                  | j                  d      d      }	| j                  j*                  }
|rt-        |      j/                  |
      nd| _        |rt-        |      j/                  |
      nd| _        |rt-        |      j/                  |
      nd| _        |	rt-        |	      j/                  |
      nd| _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _         |j                  | j                  d      d      | _!        |j                  dd      | _"        y)a{  A Microsoft planner task

        :param parent: parent object
        :type parent: Planner or Plan or Bucket
        :param Connection con: connection to use if no parent specified
        :param Protocol protocol: protocol to use if no parent specified
         (kwargs)
        :param str main_resource: use this resource instead of parent resource
         (kwargs)
        r   r   r   Nr   r   r   r   planIdbucketIdtitlepriorityassignments	orderHintassigneePrioritypercentCompletehasDescriptioncreatedDateTimedueDateTimestartDateTimecompletedDateTimer   referenceCountchecklistItemCountactiveChecklistItemCountconversationThreadIdappliedCategoriesr   )#r   r   r   r    r!   r"   r#   r$   r%   r&   r   plan_id	bucket_idr'   r   r   r   
order_hintassignee_prioritypercent_completehas_descriptiontimezoner   
astimezonestart_date_timecreated_datedue_date_timecompleted_dater(   reference_countchecklist_item_countactive_checklist_item_countconversation_thread_idapplied_categoriesr)   )r+   r   r   r,   r-   r   createdr   r   r   local_tzr.   s              r/   r&   zTask.__init__  se    cIJJ!'6::SZZ 4 4b9
 $- 

?D9 
6<GFOT2$ 	 mR8(.V__FJJz4J' 	 	
 "~~h/#
3^^DHHW$5r:
"txx
';R@%>>$((=*A2F$..+)>C!+9K0Lb!Q *txx8I/JB O  *~~dhh7G.H"M..*;!<dC"txx'>E$../)BDI#1D(EtL==)) <KE/"--h7PT 	 DKE'N55h?PT :GE- ++H5D 	 ;IE.!,,X6d 	 'NN488M+BDI)~~dhh7G.H$O$.NN488<P3QSW$X! ,6>>HH/0$,
( '1nnHH+,d'
# #-..:M1NPT"U^^M26
r0   c                 "    | j                         S r2   r3   r5   s    r/   r6   zTask.__str__{  r7   r0   c                 8    dj                  | j                        S )NzTask: {}r$   r   r5   s    r/   r4   zTask.__repr__~        ,,r0   c                 4    | j                   |j                   k(  S r2   r<   r=   s     r/   r?   zTask.__eq__  r@   r0   c                 T   | j                   st        d      | j                  | j                  j	                  d      j                  | j                               }| j                  j	                  |      }|sy|j                         } | j                  dd| i| j                  |iS zQReturns Microsoft 365/AD plan with given id

        :rtype: PlanDetails
        3Plan is not initialized correctly. Id is missing...r   rB   Nr   r9   )
r!   RuntimeErrorrQ   rR   r   r$   r   r]   task_details_constructorr    r+   ra   re   rO   s       r/   r   zTask.get_details       ~~TUUnnOO.555H
 88<<$}},t,, 

##T*
 	
r0   c                    | j                   sy| j                  | j                  j                  d      j	                  | j                               }|j                         D ]6  \  }}|dv st        |t        t        f      r|j                  d      n|||<   8 |j                         D ci c]  \  }}|dv r| j                  |      | }}}|sy| j                  j                  ||| j                  dd	      }|sy|j                         }	|D ]=  }|	j                  |d
      }|t        | | j                   j#                  |      |       ? |	j                  d      | _        yc c}}w )zUpdates this task

        :param kwargs: all the properties to be updated.
        :return: Success / Failure
        :rtype: bool
        Fr   rB   r   r   %Y-%m-%dT%H:%M:%SZ)r   r   r   r   r   r   r   r   r   r   r   r(   r   r   r   r   r   r   rJ   rK   rN   Nr   T)r!   rQ   rR   r   r$   rS   rT   r   r   strftimer'   r   r\   r)   r]   r^   r   r_   )
r+   r,   ra   kvrG   rb   rO   re   rf   s
             r/   rg   zTask.update  sp    ~~nnT__008??4>>?RSLLN 	DAq88 "!h%56 JJ34 q		 %lln
U HHSM5 
 
2 88>>!%7NO " 

 ==? 	ECLLd+E dmm77<eD	E
 \\-0
[
s   . E+c                    | j                   sy| j                  | j                  j                  d      j	                  | j                               }| j
                  j                  |d| j                  i      }|syd| _         y)zSDeletes this task

        :return: Success / Failure
        :rtype: bool
        Fr   rB   rL   rP   NTr!   rQ   rR   r   r$   r   deleter)   r+   ra   re   s      r/   r   zTask.delete  l     ~~nnT__008??4>>?RS88??3TZZ0H?Ir0   )ri   rj   rk   __doc__rR   r   r   r&   r6   r4   r?   r   rg   r   rl   rm   s   @r/   r   r     sI    " 5%J
  +!%4 Z7x-1
2AFr0   r   c                   b     e Zd ZddddZeZddd fd
Zd Zd	 Zd
 Z	d Z
ddZd Zd Z xZS )Bucketz/planner/buckets/{id}/tasksz/planner/tasksz/planner/buckets/{id})
list_taskscreate_taskbucketNr   c                   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  |d      }t        | %  |r|j                  n|j                  d      |       |j                  | j                  d	      d      | _        |j                  | j                  d
      d      | _        |j                  | j                  d      d      | _        |j                  dd      | _        y)ao  A Microsoft 365 bucket

        :param parent: parent object
        :type parent: Planner or Plan
        :param Connection con: connection to use if no parent specified
        :param Protocol protocol: protocol to use if no parent specified
         (kwargs)
        :param str main_resource: use this resource instead of parent resource
         (kwargs)
        r   r   r   Nr   r   r   r   namer   r   r   )r   r   r   r    r!   r"   r#   r$   r%   r&   r   r'   r   r   r   r)   r*   s         r/   r&   zBucket.__init__  s    cIJJ!'6::SZZ 4 4b9
 $- 

?D9 
6<GFOT2$ 	 mR8(.V__FJJz4J' 	 	
 NN488F#3R8	$..+)>C!~~dhhx&8"=^^M26
r0   c                 "    | j                         S r2   r3   r5   s    r/   r6   zBucket.__str__&  r7   r0   c                 8    dj                  | j                        S )Nz
Bucket: {})r$   r   r5   s    r/   r4   zBucket.__repr__)  s    ""499--r0   c                 4    | j                   |j                   k(  S r2   r<   r=   s     r/   r?   zBucket.__eq__,  r@   r0   c           	         | j                   st        d      | j                  | j                  j	                  d      j                  | j                               }| j                  j	                  |      }|sy|j                         }|j	                  dg       D cg c]"  } | j                  dd| i| j                  |i$ c}S c c}w )zMReturns list of tasks that given plan has
        :rtype: list[Task]
        z5Bucket is not initialized correctly. Id is missing...r   rB   Nrb   r   r9   )
r!   r   rQ   rR   r   r$   r   r]   task_constructorr    )r+   ra   re   rO   r   s        r/   r   zBucket.list_tasks/  s    
 ~~VWWnnOO-444G
 88<<$}} "-
 "D!!NN$2F2F1MN
 	
 
   'Cc                    |st        d      | j                  s| j                  sy| j                  | j                  j                  d            }|sddi}|j                         D ]6  \  }}|dv st        |t        t        f      r|j                  d      n|||<   8 |j                         D ci c]  \  }}|dv r| j                  |      | }}}||| j                  | j                  d	|}	| j                  j                  ||	
      }
|
sy|
j                         } | j                  dd| i| j                   |iS c c}}w )ao  Creates a Task

        :param str title: the title of the task
        :param dict assignments: the dict of users to which tasks are to be assigned.

        .. code-block:: python

            e.g. assignments = {
                  "ca2a1df2-e36b-4987-9f6b-0ea462f4eb47": null,
                  "4e98f8f1-bb03-4015-b8e0-19bb370949d8": {
                      "@odata.type": "microsoft.graph.plannerAssignment",
                      "orderHint": "String"
                    }
                }
            if "user_id": null -> task is unassigned to user.
            if "user_id": dict -> task is assigned to user

        :param dict kwargs: optional extra parameters to include in the task
        :param int priority: priority of the task. The valid range of values is between 0 and 10.

            1 -> "urgent", 3 -> "important", 5 -> "medium", 9 -> "low" (kwargs)

        :param str order_hint: the order of the bucket. Default is on top (kwargs)
        :param datetime or str start_date_time: the starting date of the task. If str format should be: "%Y-%m-%dT%H:%M:%SZ" (kwargs)
        :param datetime or str due_date_time: the due date of the task. If str format should be: "%Y-%m-%dT%H:%M:%SZ" (kwargs)
        :param str conversation_thread_id: thread ID of the conversation on the task.

            This is the ID of the conversation thread object created in the group (kwargs)

        :param str assignee_priority: hint used to order items of this type in a list view (kwargs)
        :param int percent_complete: percentage of task completion. When set to 100, the task is considered completed (kwargs)
        :param dict applied_categories: The categories (labels) to which the task has been applied.

            Format should be e.g. {"category1": true, "category3": true, "category5": true } should (kwargs)

        :return: newly created task
        :rtype: Task
        zProvide a title for the TaskNr   rC   z"microsoft.graph.plannerAssignmentsr   r   priorityorder_hintassignee_prioritypercent_completehas_descriptionstart_date_timecreated_datedue_date_timecompleted_datepreview_typereference_countchecklist_item_countactive_checklist_item_countconversation_thread_idapplied_categories)r   r   r   r   rO   r   r9   )r   r!   r   rQ   rR   r   rS   rT   r   r   r   r'   r   postr]   r   r    )r+   r   r   r,   ra   r   r   rG   rb   rO   re   r   s               r/   r   zBucket.create_taskG  s\   N =>>~~dllnnT__00?@(*NOKLLN 	DAq88 "!h%56 JJ34 q		 %lln
U% HHSM5 
 
0 &ll	

 
 88==4=0}}$t$$QDQT5I5I44PQQK
s   3 Ec                 P   | j                   sy| j                  | j                  j                  d      j	                  | j                               }|j                         D ci c]  \  }}|dv r| j                  |      | }}}|sy| j                  j                  ||| j                  dd      }|sy|j                         }|D ]=  }|j                  |d      }|t        | | j                  j                  |      |       ? |j                  d	      | _	        y
c c}}w )zUpdates this bucket

        :param kwargs: all the properties to be updated.
        :return: Success / Failure
        :rtype: bool
        Fr   rB   )r   r   rJ   rK   rN   Nr   Tr{   r|   s           r/   rg   zBucket.update  s    ~~nnT__00:AAT^^ATU %lln
U,, HHSM5 
 

 88>>!%7NO " 

 ==? 	ECLLd+E dmm77<eD	E
 \\-0
3
r}   c                    | j                   sy| j                  | j                  j                  d      j	                  | j                               }| j
                  j                  |d| j                  i      }|syd| _         y)zUDeletes this bucket

        :return: Success / Failure
        :rtype: bool
        Fr   rB   rL   r   NTr   r   s      r/   r   zBucket.delete  sl     ~~nnT__00:AAT^^ATU88??3TZZ0H?Ir0   r2   )ri   rj   rk   rR   r   r   r&   r6   r4   r?   r   r   rg   r   rl   rm   s   @r/   r   r     sM    3')J
 !%4 '7R.1
0_RB%Nr0   r   c                   z     e Zd ZddddddZeZeZeZ	ddd fd	
Z
d
 Zd Zd Zd Zd Zd ZddZd Zd Z xZS )Planz/planner/plans/{id}/bucketsz/planner/plans/{id}/tasksrq   z/planner/plans/{id}z/planner/buckets)list_bucketsr   r   plancreate_bucketNr   c                   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  |d      }t        | %  |r|j                  n|j                  d      |       |j                  | j                  d	      d      | _        |j                  | j                  d
      i       }|j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  dd      | _        y)ae  A Microsoft 365 plan

        :param parent: parent object
        :type parent: Planner
        :param Connection con: connection to use if no parent specified
        :param Protocol protocol: protocol to use if no parent specified
         (kwargs)
        :param str main_resource: use this resource instead of parent resource
         (kwargs)
        r   r   r   Nr   r   r   r   r   	containercontainerIdr   r   )r   r   r   r    r!   r"   r#   r$   r%   r&   r   r'   created_date_timegroup_idr   r)   )r+   r   r   r,   r-   r   r   r.   s          r/   r&   zPlan.__init__  s2    cIJJ!'6::SZZ 4 4b9
 $- 

?D9 
6<GFOT2$ 	 mR8(.V__FJJz4J' 	 	
 ",9J0KR!PNN488K#8"=	!dhh}&=rB^^DHHW$5r:
^^M26
r0   c                 "    | j                         S r2   r3   r5   s    r/   r6   zPlan.__str__  r7   r0   c                 8    dj                  | j                        S )NzPlan: {}r   r5   s    r/   r4   zPlan.__repr__  r   r0   c                 4    | j                   |j                   k(  S r2   r<   r=   s     r/   r?   zPlan.__eq__!  r@   r0   c           	         | j                   st        d      | j                  | j                  j	                  d      j                  | j                               }| j                  j	                  |      }|sy|j                         }|j	                  dg       D cg c]"  } | j                  dd| i| j                  |i$ c}S c c}w )zQReturns list of buckets that given plan has
        :rtype: list[Bucket]
        r   r   rB   Nrb   r   r9   )
r!   r   rQ   rR   r   r$   r   r]   bucket_constructorr    )r+   ra   re   rO   r   s        r/   r   zPlan.list_buckets$  s    
 ~~TUUnnOO/66$..6I
 88<<$}} ((7B/
 $D##R4RD4H4H&3QR
 	
 
r   c           	          | j                   st        d      | j                  | j                  j	                  d      j                  | j                               }| j                  j	                  |      }|sg S |j                         }|j	                  t        d      }|j	                  dg       D cg c]"  } | j                  dd| i| j                  |i$ }}|rt        | || j                  |      S |S c c}w )	zcReturns list of tasks that given plan has
        :rtype: list[Task] or Pagination of Task
        r   r   rB   Nrb   r   )r   rO   constructor	next_linkr9   )r!   r   rQ   rR   r   r$   r   r]   r   r   r    r	   )r+   ra   re   rO   r   r   taskss          r/   r   zPlan.list_tasks<  s    
 ~~TUUnnOO-444G
 88<<$I}}HH.5	 "-
 "D!!NN$2F2F1MN
 

  11#	  L
s   5'C;c                 T   | j                   st        d      | j                  | j                  j	                  d      j                  | j                               }| j                  j	                  |      }|sy|j                         } | j                  dd| i| j                  |iS r   )
r!   r   rQ   rR   r   r$   r   r]   plan_details_constructorr    r   s       r/   r   zPlan.get_details_  r   r0   c                 J   |st        d      | j                  sy| j                  | j                  j	                  d            }||| j                  d}| j
                  j                  ||      }|sy|j                         } | j                  dd| i| j                  |iS )a^  Creates a Bucket

        :param str name: the name of the bucket
        :param str order_hint: the order of the bucket. Default is on top.
            How to use order hints here: https://docs.microsoft.com/en-us/graph/api/resources/planner-order-hint-format?view=graph-rest-1.0
        :return: newly created bucket
        :rtype: Bucket
        zProvide a name for the BucketNr   )r   r   r   r   r   r9   )
r   r!   rQ   rR   r   r   r   r]   r   r    )r+   r   r   ra   rO   re   r   s          r/   r   zPlan.create_bucketx  s     >??~~nnT__00AB:P88==4=0&t&&UdUt7K7KV6TUUr0   c                 R   | j                   sy| j                  | j                  j                  d      j	                  | j                               }|j                         D ci c]  \  }}|dv s| j                  |      | }}}|sy| j                  j                  ||| j                  dd      }|sy|j                         }|D ]=  }|j                  |d      }|t        | | j                  j                  |      |       ? |j                  d	      | _	        y
c c}}w )zUpdates this plan

        :param kwargs: all the properties to be updated.
        :return: Success / Failure
        :rtype: bool
        Fr   rB   r   rJ   rK   rN   Nr   Tr{   r|   s           r/   rg   zPlan.update  s    ~~nnT__008??4>>?RS 4:<<>
%/S%SWEUDHHSM5 
 
 88>>!%7NO " 

 ==? 	ECLLd+E dmm77<eD	E
 \\-0
/
s   %D#2D#c                    | j                   sy| j                  | j                  j                  d      j	                  | j                               }| j
                  j                  |d| j                  i      }|syd| _         y)zSDeletes this plan

        :return: Success / Failure
        :rtype: bool
        Fr   rB   rL   r   NTr   r   s      r/   r   zPlan.delete  r   r0   )z !)ri   rj   rk   rR   r   r   r   r   ro   r   r&   r6   r4   r?   r   r   r   r   rg   r   rl   rm   s   @r/   r   r     sh    514%+J  *!%4 (7T-1
0!F
2V8#Jr0   r   c                        e Zd ZdZdddddddd	ZeZeZe	Z
d
d
d fd
Zd Zd Zd ZddZddZddZddZddZddZ xZS )PlannerzA microsoft planner class

    In order to use the API following permissions are required.
    Delegated (work or school account) - Group.Read.All, Group.ReadWrite.All
    z/me/planner/tasksz/planner/plans/{plan_id}z/planner/buckets/{bucket_id}z/planner/tasks/{task_id}z/users/{user_id}/planner/tasksz /groups/{group_id}/planner/plansz/planner/plans)get_my_tasksget_plan_by_idget_bucket_by_idget_task_by_idlist_user_taskslist_group_planscreate_planNr   c                    |r|rt        d      |r|j                  n|| _        |j                  dd      }t        |   |r|j
                  n|j                  d      |       y)aa  A Planner object

        :param parent: parent object
        :type parent: Account
        :param Connection con: connection to use if no parent specified
        :param Protocol protocol: protocol to use if no parent specified
         (kwargs)
        :param str main_resource: use this resource instead of parent resource
         (kwargs)
        r   r   r   r   r   N)r   r   r"   r%   r&   r   r   )r+   r   r   r,   r   r.   s        r/   r&   zPlanner.__init__  s`     cIJJ!'6::S 

?B7(.V__FJJz4J' 	 	
r0   c                 "    | j                         S r2   r3   r5   s    r/   r6   zPlanner.__str__  r7   r0   c                      y)NzMicrosoft Plannerr9   r5   s    r/   r4   zPlanner.__repr__  s    "r0   c           	      8   | j                  | j                  j                  d            }| j                  j                  |      }|sy|j	                         }|j                  dg       D cg c]"  } | j
                  dd| i| j                  |i$ c}S c c}w )zSReturns a list of open planner tasks assigned to me

        :rtype: tasks
        r   Nrb   r   r9   )rQ   rR   r   r   r]   r   r    )r+   argsra   re   rO   sites         r/   r   zPlanner.get_my_tasks  s     nnT__00@A88<<$}} "-
 "D!!NN$2F2F1MN
 	
 
s   -'Bc                 ,   |st        d      | j                  | j                  j                  d      j	                  |            }| j
                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )zsReturns Microsoft 365/AD plan with given id

        :param plan_id: plan id of plan

        :rtype: Plan
        zProvide the plan_idr   )r   Nr   r9   	r   rQ   rR   r   r$   r   r]   plan_constructorr    )r+   r   ra   re   rO   s        r/   r   zPlanner.get_plan_by_id  s     455nnOO 01888I
 88<<$}}$t$$ 

##T*
 	
r0   c                 ,   |st        d      | j                  | j                  j                  d      j	                  |            }| j
                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )z|Returns Microsoft 365/AD plan with given id

        :param bucket_id: bucket id of buckets

        :rtype: Bucket
        zProvide the bucket_idr   )r   Nr   r9   )	r   rQ   rR   r   r$   r   r]   r   r    )r+   r   ra   re   rO   s        r/   r   zPlanner.get_bucket_by_id-  s     677nnOO 23::Y:O
 88<<$}}&t&&SdSt7K7KT6RSSr0   c                 ,   |st        d      | j                  | j                  j                  d      j	                  |            }| j
                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )ztReturns Microsoft 365/AD plan with given id

        :param task_id: task id of tasks

        :rtype: Task
        zProvide the task_idr   )task_idNr   r9   	r   rQ   rR   r   r$   r   r]   r   r    )r+   r   ra   re   rO   s        r/   r   zPlanner.get_task_by_idE  s     455nnOO 01888I
 88<<$}}$t$$QDQT5I5I44PQQr0   c           	      r   |st        d      | j                  | j                  j                  d      j	                  |            }| j
                  j                  |      }|sy|j                         }|j                  dg       D cg c]"  } | j                  dd| i| j                  |i$ c}S c c}w )zqReturns Microsoft 365/AD plan with given id

        :param user_id: user id

        :rtype: list[Task]
        zProvide the user_idr   )user_idNrb   r   r9   r  )r+   r  ra   re   rO   r   s         r/   r   zPlanner.list_user_tasks]  s     455nnOO 1299'9J
 88<<$}} "-
 "D!!NN$2F2F1MN
 	
 
   
'B4c           	      r   |st        d      | j                  | j                  j                  d      j	                  |            }| j
                  j                  |      }|sy|j                         }|j                  dg       D cg c]"  } | j                  dd| i| j                  |i$ c}S c c}w )zpReturns list of plans that given group has
        :param group_id: group id
        :rtype: list[Plan]
        zProvide the group_idr   )r   Nrb   r   r9   r   )r+   r   ra   re   rO   r   s         r/   r   zPlanner.list_group_plansx  s     566nnOO 23::H:M
 88<<$}} "-
 "D!!NN$2F2F1MN
 	
 
r  c                    |st        d      | j                  | j                  j                  d            }||d}| j                  j                  ||      }|sy|j                         } | j                  dd| i| j                  |iS )zCreates a Plan

        :param str owner: the id of the group that will own the plan
        :param str title: the title of the new plan. Default set to "Tasks"
        :return: newly created plan
        :rtype: Plan
        zProvide the owner (group_id)r   )ownerr   r   Nr   r9   )	r   rQ   rR   r   r   r   r]   r   r    )r+   r  r   ra   rO   re   r   s          r/   r   zPlanner.create_plan  s     =>>nnT__00?@/88==4=0}}$t$$QDQT5I5I44PQQr0   r2   )Tasks)ri   rj   rk   r   rR   r   r   r   r   r   r   r&   r6   r4   r   r   r   r   r   r   r   rl   rm   s   @r/   r   r     st     ,4:4;>'J !%4 
,#
(
6T0R0
6
2Rr0   r   )loggingr   r   dateutil.parserr   utilsr   r   r	   	getLoggerri   logr   ro   r   r   r   r   r9   r0   r/   <module>r     s     # ! > >g!e, eP_, _D]< ]@l\ l^g< gTXRl XRr0   