def get_parent(self, **kwargs): """ Return the object that spawned this content migration. :rtype: :class:`canvasapi.group.Account`, or :class:`canvasapi.course.Course`, or :class:`canvasapi.course.Group`, or :class:`canvasapi.course.User` """ from canvasapi.account import Account from canvasapi.course import Course from canvasapi.group import Group from canvasapi.user import User response = self._requester.request( "GET", "{}s/{}".format(self._parent_type, self._parent_id), _kwargs=combine_kwargs(**kwargs), ) if self._parent_type == "group": return Group(self._requester, response.json()) elif self._parent_type == "course": return Course(self._requester, response.json()) elif self._parent_type == "account": return Account(self._requester, response.json()) elif self._parent_type == "user": return User(self._requester, response.json())
def get_group(self, group, use_sis_id=False, **kwargs): """ Return the data for a single group. If the caller does not have permission to view the group a 401 will be returned. :calls: `GET /api/v1/groups/:group_id \ <https://canvas.instructure.com/doc/api/groups.html#method.groups.show>`_ :param group: The object or ID of the group to get. :type group: :class:`canvasapi.group.Group` or int :param use_sis_id: Whether or not group_id is an sis ID. Defaults to `False`. :type use_sis_id: bool :rtype: :class:`canvasapi.group.Group` """ if use_sis_id: group_id = group uri_str = 'groups/sis_group_id:{}' else: group_id = obj_or_id(group, "group", (Group, )) uri_str = 'groups/{}' response = self.__requester.request('GET', uri_str.format(group_id), _kwargs=combine_kwargs(**kwargs)) return Group(self.__requester, response.json())
def create_group(self, **kwargs): """ Create a group :calls: `POST /api/v1/groups/ \ <https://canvas.instructure.com/doc/api/groups.html#method.groups.create>`_ :rtype: :class:`canvasapi.group.Group` """ response = self.__requester.request('POST', 'groups', **combine_kwargs(**kwargs)) return Group(self.__requester, response.json())
def get_group(self, group_id, **kwargs): """ Return the data for a single group. If the caller does not have permission to view the group a 401 will be returned. :calls: `GET /api/v1/groups/:group_id \ <https://canvas.instructure.com/doc/api/groups.html#method.groups.show>`_ :rtype: :class:`canvasapi.group.Group` """ response = self.__requester.request('GET', 'groups/%s' % (group_id), **combine_kwargs(**kwargs)) return Group(self.__requester, response.json())
def get_parent(self): """ Return the object that spawned this discussion topic. :rtype: :class:`canvasapi.group.Group` or :class:`canvasapi.course.Course` """ from canvasapi.group import Group from canvasapi.course import Course response = self._requester.request( 'GET', '{}s/{}'.format(self._parent_type, self._parent_id)) if self._parent_type == 'group': return Group(self._requester, response.json()) elif self._parent_type == 'course': return Course(self._requester, response.json())
def get_parent(self, **kwargs): """ Return the object that spawned this discussion topic. :rtype: :class:`canvasapi.group.Group` or :class:`canvasapi.course.Course` """ from canvasapi.group import Group from canvasapi.course import Course response = self._requester.request( "GET", "{}s/{}".format(self._parent_type, self._parent_id), _kwargs=combine_kwargs(**kwargs), ) if self._parent_type == "group": return Group(self._requester, response.json()) elif self._parent_type == "course": return Course(self._requester, response.json())
def get_parent(self): """ Return the object that spawned this page. :calls: `GET /api/v1/groups/:group_id \ <https://canvas.instructure.com/doc/api/groups.html#method.groups.show>`_ or :calls: `GET /api/v1/courses/:course_id \ <https://canvas.instructure.com/doc/api/courses.html#method.courses.show>`_ :rtype: :class:`canvasapi.group.Group` or :class:`canvasapi.course.Course` """ from canvasapi.group import Group from canvasapi.course import Course response = self._requester.request( 'GET', '{}s/{}'.format(self.parent_type, self.parent_id)) if self.parent_type == 'group': return Group(self._requester, response.json()) elif self.parent_type == 'course': return Course(self._requester, response.json())
def get_parent(self, **kwargs): """ Return the object that spawned this page. :calls: `GET /api/v1/groups/:group_id \ <https://canvas.instructure.com/doc/api/groups.html#method.groups.show>`_ or :calls: `GET /api/v1/courses/:id \ <https://canvas.instructure.com/doc/api/courses.html#method.courses.show>`_ :rtype: :class:`canvasapi.group.Group` or :class:`canvasapi.course.Course` """ from canvasapi.group import Group from canvasapi.course import Course response = self._requester.request( "GET", "{}s/{}".format(self.parent_type, self.parent_id), _kwargs=combine_kwargs(**kwargs), ) if self.parent_type == "group": return Group(self._requester, response.json()) elif self.parent_type == "course": return Course(self._requester, response.json())