def getProjects(self): """Get projects REST: GET /projects.xml Returns all accessible projects. This includes active, inactive, and archived projects. """ path = '/projects.xml' rootElement = self.fromXML(self.get(path).contents) # TODO: use special Array attribute projects = [] for data in rootElement.getElementsByTagName('project'): projects.append(Project.load(data)) return projects
def getProjectById(self, project_id): """Get project REST: GET /projects/#{project_id}.xml Returns a single project identified by its integer ID """ # ensure that we got numerical project id assert isinstance(project_id, int) path = '/projects/%d.xml' % project_id response = self.get(path) if response.status == 404: raise NotFoundError, 'Project with %d id is not found!' % project_id rootElement = self.fromXML(response.contents) return Project.load(rootElement)