def list_folders(self): """List all folders accessible to the authenticated user API Endpoint: GET /folders :return: a list of folders :rtype: list() :raises FossologyApiError: if the REST call failed """ response = self.session.get(f"{self.api}/folders") if response.status_code == 200: folders_list = list() response_list = response.json() for folder in response_list: sub_folder = Folder.from_json(folder) folders_list.append(sub_folder) return folders_list else: description = f"Unable to get a list of folders for {self.user.name}" raise FossologyApiError(description, response)
def detail_folder(self, folder_id): """Get details of folder. API Endpoint: GET /folders/{id} :param id: the ID of the folder to be analysed :type id: int :return: the requested folder :rtype: Folder() object :raises FossologyApiError: if the REST call failed """ response = self.session.get(f"{self.api}/folders/{folder_id}") if response.status_code == 200: detailled_folder = Folder.from_json(response.json()) for folder in self.folders: if folder.id == folder_id: self.folders.remove(folder) self.folders.append(detailled_folder) return detailled_folder else: description = f"Error while getting details for folder {folder_id}" raise FossologyApiError(description, response)