Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
:calls: `GET /api/v1/folders/:id \
`_
:param folder: The object or ID of the folder to retrieve.
:type folder: :class:`canvasapi.folder.Folder` or int
:rtype: :class:`canvasapi.folder.Folder`
"""
folder_id = obj_or_id(folder, "folder", (Folder,))
response = self.__requester.request(
'GET',
'folders/{}'.format(folder_id)
)
return Folder(self.__requester, response.json())
:calls: `GET /api/v1/folders/:id \
`_
:param folder: The object or ID of the folder to retrieve.
:type folder: :class:`canvasapi.folder.Folder` or int
:rtype: :class:`canvasapi.folder.Folder`
"""
folder_id = obj_or_id(folder, "folder", (Folder,))
response = self.__requester.request(
'GET',
'folders/{}'.format(folder_id)
)
return Folder(self.__requester, response.json())
def test_create_folder(self, m):
register_uris({"group": ["create_folder"]}, m)
name_str = "Test String"
response = self.group.create_folder(name=name_str)
self.assertIsInstance(response, Folder)
def passes_multiple_endpoints(self, folder):
"""
Return the details for a folder
:calls: `GET /api/v1/folders/:id \
`_
:param folder: The object or ID of the folder to retrieve.
:type folder: :class:`canvasapi.folder.Folder` or int
:rtype: :class:`canvasapi.folder.Folder`
"""
folder_id = obj_or_id(folder, "folder", (Folder,))
response = self.__requester.request(
'GET',
'folders/{}'.format(folder_id)
)
return Folder(self.__requester, response.json())
Creates a folder in this group.
:calls: `POST /api/v1/groups/:group_id/folders \
`_
:param name: The name of the folder.
:type name: str
:rtype: :class:`canvasapi.folder.Folder`
"""
response = self._requester.request(
"POST",
"groups/{}/folders".format(self.id),
name=name,
_kwargs=combine_kwargs(**kwargs),
)
return Folder(self._requester, response.json())
def get_folders(self, **kwargs):
"""
Returns the paginated list of folders in the folder.
:calls: `GET /api/v1/folders/:id/folders \
`_
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.folder.Folder`
"""
return PaginatedList(
Folder,
self._requester,
'GET',
'folders/{}/folders'.format(self.id)
)
:calls: `PUT /api/v1/folders/:id \
`_
:rtype: :class:`canvasapi.folder.Folder`
"""
response = self._requester.request(
'PUT',
'folders/{}'.format(self.id),
_kwargs=combine_kwargs(**kwargs)
)
if 'name' in response.json():
super(Folder, self).set_attributes(response.json())
return Folder(self._requester, response.json())
def get_folders(self, **kwargs):
"""
Returns the paginated list of all folders for the given user. This will be returned as a
flat list containing all subfolders as well.
:calls: `GET /api/v1/users/:user_id/folders \
`_
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.folder.Folder`
"""
return PaginatedList(
Folder,
self._requester,
"GET",
"users/{}/folders".format(self.id),
_kwargs=combine_kwargs(**kwargs),
)
"""
Updates a folder.
:calls: `PUT /api/v1/folders/:id \
`_
:rtype: :class:`canvasapi.folder.Folder`
"""
response = self._requester.request(
'PUT',
'folders/{}'.format(self.id),
_kwargs=combine_kwargs(**kwargs)
)
if 'name' in response.json():
super(Folder, self).set_attributes(response.json())
return Folder(self._requester, response.json())
Returns the details for a course folder
:calls: `GET /api/v1/courses/:course_id/folders/:id \
`_
:param folder: The object or ID of the folder to retrieve.
:type folder: :class:`canvasapi.folder.Folder` or int
:rtype: :class:`canvasapi.folder.Folder`
"""
folder_id = obj_or_id(folder, "folder", (Folder,))
response = self._requester.request(
"GET", "courses/{}/folders/{}".format(self.id, folder_id)
)
return Folder(self._requester, response.json())