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/: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_course(self, course_id, use_sis_id=False, **kwargs): """ Retrieve a course by its ID. :calls: `GET /courses/:id \ <https://canvas.instructure.com/doc/api/courses.html#method.courses.show>`_ :param course_id: The ID of the course to retrieve. :type course_id: int or str :param use_sis_id: Whether or not course_id is an sis ID. Defaults to `False`. :type use_sis_id: bool :rtype: :class:`canvasapi.course.Course` """ if use_sis_id: uri_str = 'courses/sis_course_id:{}' else: uri_str = 'courses/{}' response = self.__requester.request('GET', uri_str.format(course_id), _kwargs=combine_kwargs(**kwargs)) return Course(self.__requester, response.json())