|
23 | 23 | from canvasapi.grading_period import GradingPeriod |
24 | 24 | from canvasapi.grading_standard import GradingStandard |
25 | 25 | from canvasapi.license import License |
| 26 | +from canvasapi.lti_resource_link import LTIResourceLink |
26 | 27 | from canvasapi.module import Module |
27 | 28 | from canvasapi.new_quiz import NewQuiz |
28 | 29 | from canvasapi.outcome_import import OutcomeImport |
@@ -438,6 +439,39 @@ def create_late_policy(self, **kwargs): |
438 | 439 |
|
439 | 440 | return LatePolicy(self._requester, late_policy_json["late_policy"]) |
440 | 441 |
|
| 442 | + def create_lti_resource_link(self, url, title=None, custom=None, **kwargs): |
| 443 | + """ |
| 444 | + Create a new LTI resource link. |
| 445 | +
|
| 446 | + :calls: `POST /api/v1/courses/:course_id/lti_resource_links \ |
| 447 | + <https://canvas.instructure.com/doc/api/lti_resource_links.html#method.lti/resource_links.create>`_ |
| 448 | +
|
| 449 | + :param url: The launch URL for the resource link. |
| 450 | + :type url: `str` |
| 451 | + :param title: The title of the resource link. |
| 452 | + :type title: `str`, optional |
| 453 | + :param custom: Custom parameters to send to the tool. |
| 454 | + :type custom: `dict`, optional |
| 455 | +
|
| 456 | + :rtype: :class:`canvasapi.lti_resource_link.LTIResourceLink` |
| 457 | + """ |
| 458 | + |
| 459 | + if not url: |
| 460 | + raise RequiredFieldMissing("url is required as a str.") |
| 461 | + |
| 462 | + kwargs["url"] = url |
| 463 | + if title: |
| 464 | + kwargs["title"] = title |
| 465 | + if custom: |
| 466 | + kwargs["custom"] = custom |
| 467 | + |
| 468 | + response = self._requester.request( |
| 469 | + "POST", |
| 470 | + f"courses/{self.id}/lti_resource_links", |
| 471 | + _kwargs=combine_kwargs(**kwargs), |
| 472 | + ) |
| 473 | + return LTIResourceLink(self._requester, response.json()) |
| 474 | + |
441 | 475 | def create_module(self, module, **kwargs): |
442 | 476 | """ |
443 | 477 | Create a new module. |
@@ -1645,6 +1679,49 @@ def get_licenses(self, **kwargs): |
1645 | 1679 | _kwargs=combine_kwargs(**kwargs), |
1646 | 1680 | ) |
1647 | 1681 |
|
| 1682 | + def get_lti_resource_link(self, lti_resource_link, **kwargs): |
| 1683 | + """ |
| 1684 | + Return details about the specified resource link. |
| 1685 | +
|
| 1686 | + :calls: `GET /api/v1/courses/:course_id/lti_resource_links/:id \ |
| 1687 | + <https://canvas.instructure.com/doc/api/lti_resource_links.html#method.lti/resource_links.show>`_ |
| 1688 | +
|
| 1689 | + :param lti_resource_link: The object or ID of the LTI resource link. |
| 1690 | + :type lti_resource_link: :class:`canvasapi.lti_resource_link.LTIResourceLink` or int |
| 1691 | +
|
| 1692 | + :rtype: :class:`canvasapi.lti_resource_link.LTIResourceLink` |
| 1693 | + """ |
| 1694 | + |
| 1695 | + lti_resource_link_id = obj_or_id( |
| 1696 | + lti_resource_link, "lti_resource_link", (LTIResourceLink,) |
| 1697 | + ) |
| 1698 | + |
| 1699 | + response = self._requester.request( |
| 1700 | + "GET", |
| 1701 | + f"courses/{self.id}/lti_resource_links/{lti_resource_link_id}", |
| 1702 | + _kwargs=combine_kwargs(**kwargs), |
| 1703 | + ) |
| 1704 | + return LTIResourceLink(self._requester, response.json()) |
| 1705 | + |
| 1706 | + def get_lti_resource_links(self, **kwargs): |
| 1707 | + """ |
| 1708 | + Returns all LTI resource links for this course as a PaginatedList. |
| 1709 | +
|
| 1710 | + :calls: `GET /api/v1/courses/:course_id/lti_resource_links \ |
| 1711 | + <https://canvas.instructure.com/doc/api/lti_resource_links.html#method.lti/resource_links.index>`_ |
| 1712 | +
|
| 1713 | + :rtype: :class:`canvasapi.paginated_list.PaginatedList` of |
| 1714 | + :class:`canvasapi.lti_resource_link.LTIResourceLink` |
| 1715 | + """ |
| 1716 | + |
| 1717 | + return PaginatedList( |
| 1718 | + LTIResourceLink, |
| 1719 | + self._requester, |
| 1720 | + "GET", |
| 1721 | + f"courses/{self.id}/lti_resource_links", |
| 1722 | + kwargs=combine_kwargs(**kwargs), |
| 1723 | + ) |
| 1724 | + |
1648 | 1725 | def get_migration_systems(self, **kwargs): |
1649 | 1726 | """ |
1650 | 1727 | Return a list of migration systems. |
|
0 commit comments