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. e.g. assignments = { "ca2a1df2-e36b-4987-9f6b-0ea462f4eb47": null, "4e98f8f1-bb03-4015-b8e0-19bb37094
(self, title, assignments=None, **kwargs)
| 460 | for task in data.get('value', [])] |
| 461 | |
| 462 | def create_task(self, title, assignments=None, **kwargs): |
| 463 | """ Creates a Task |
| 464 | |
| 465 | :param str title: the title of the task |
| 466 | :param dict assignments: the dict of users to which tasks are to be assigned. |
| 467 | e.g. assignments = { |
| 468 | "ca2a1df2-e36b-4987-9f6b-0ea462f4eb47": null, |
| 469 | "4e98f8f1-bb03-4015-b8e0-19bb370949d8": { |
| 470 | "@odata.type": "microsoft.graph.plannerAssignment", |
| 471 | "orderHint": "String" |
| 472 | } |
| 473 | } |
| 474 | if "user_id": null -> task is unassigned to user. if "user_id": dict -> task is assigned to user |
| 475 | :param dict kwargs: optional extra parameters to include in the task |
| 476 | :param int priority: priority of the task. The valid range of values is between 0 and 10, |
| 477 | 1 -> "urgent", 3 -> "important", 5 -> "medium", 9 -> "low" (kwargs) |
| 478 | :param str order_hint: the order of the bucket. Default is on top (kwargs) |
| 479 | :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) |
| 480 | :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) |
| 481 | :param str conversation_thread_id: thread ID of the conversation on the task. |
| 482 | This is the ID of the conversation thread object created in the group (kwargs) |
| 483 | :param str assignee_priority: hint used to order items of this type in a list view (kwargs) |
| 484 | :param int percent_complete: percentage of task completion. When set to 100, the task is considered completed (kwargs) |
| 485 | :param dict applied_categories: The categories (labels) to which the task has been applied. |
| 486 | Format should be e.g. {"category1": true, "category3": true, "category5": true } should (kwargs) |
| 487 | :return: newly created task |
| 488 | :rtype: Task |
| 489 | """ |
| 490 | if not title: |
| 491 | raise RuntimeError('Provide a title for the Task') |
| 492 | |
| 493 | if not self.object_id and not self.plan_id: |
| 494 | return None |
| 495 | |
| 496 | url = self.build_url( |
| 497 | self._endpoints.get('create_task')) |
| 498 | |
| 499 | if not assignments: |
| 500 | assignments = {'@odata.type': 'microsoft.graph.plannerAssignments'} |
| 501 | |
| 502 | for k, v in kwargs.items(): |
| 503 | if k in ('start_date_time', 'due_date_time'): |
| 504 | kwargs[k] = v.strftime('%Y-%m-%dT%H:%M:%SZ') if isinstance(v, (datetime, date)) else v |
| 505 | |
| 506 | kwargs = {self._cc(key): value for key, value in kwargs.items() if |
| 507 | key in ( |
| 508 | 'priority' |
| 509 | 'order_hint' |
| 510 | 'assignee_priority' |
| 511 | 'percent_complete' |
| 512 | 'has_description' |
| 513 | 'start_date_time' |
| 514 | 'created_date' |
| 515 | 'due_date_time' |
| 516 | 'completed_date' |
| 517 | 'preview_type' |
| 518 | 'reference_count' |
| 519 | 'checklist_item_count' |