MCPcopy Index your code
hub / github.com/O365/python-o365 / update

Method update

O365/planner.py:310–364  ·  view source on GitHub ↗

Updates this task :param kwargs: all the properties to be updated. :return: Success / Failure :rtype: bool

(self, **kwargs)

Source from the content-addressed store, hash-verified

308 **{self._cloud_data_key: data}, )
309
310 def update(self, **kwargs):
311 """ Updates this task
312
313 :param kwargs: all the properties to be updated.
314 :return: Success / Failure
315 :rtype: bool
316 """
317 if not self.object_id:
318 return False
319
320 url = self.build_url(
321 self._endpoints.get('task').format(id=self.object_id))
322
323 for k, v in kwargs.items():
324 if k in ('start_date_time', 'due_date_time'):
325 kwargs[k] = v.strftime('%Y-%m-%dT%H:%M:%SZ') if isinstance(v, (datetime, date)) else v
326
327 data = {self._cc(key): value for key, value in kwargs.items() if
328 key in (
329 'title',
330 'priority',
331 'assignments',
332 'order_hint',
333 'assignee_priority',
334 'percent_complete',
335 'has_description',
336 'start_date_time',
337 'created_date',
338 'due_date_time',
339 'completed_date',
340 'preview_type',
341 'reference_count',
342 'checklist_item_count',
343 'active_checklist_item_count',
344 'conversation_thread_id',
345 'applied_categories',
346 'bucket_id'
347 )}
348 if not data:
349 return False
350
351 response = self.con.patch(url, data=data, headers={'If-Match': self._etag, 'Prefer': 'return=representation'})
352 if not response:
353 return False
354
355 new_data = response.json()
356
357 for key in data:
358 value = new_data.get(key, None)
359 if value is not None:
360 setattr(self, self.protocol.to_api_case(key), value)
361
362 self._etag = new_data.get('@odata.etag')
363
364 return True
365
366 def delete(self):
367 """ Deletes this task

Callers

nothing calls this directly

Calls 6

build_urlMethod · 0.80
_ccMethod · 0.80
jsonMethod · 0.80
to_api_caseMethod · 0.80
getMethod · 0.45
patchMethod · 0.45

Tested by

no test coverage detected