def getProject(self, id): try: response = self.getResource("/projects/%s" % id, "GET") except requests.exceptions.HTTPError as ex: response = ex.response.json() raise SynergyError("error on retrieving the project (id=%r, " "msg=%s)" % (id, response["error"]["message"])) project = None if response: info = response["project"] project = Project() project.setId(info["id"]) project.setName(info["name"]) project.setEnabled(info["enabled"]) return project
def getProject(self, id): try: response = self.getResource("/projects/%s" % id, "GET") except requests.exceptions.HTTPError as ex: response = ex.response.json() raise SynergyError("error on retrieving the project (id=%r, " "msg=%s)" % (id, response["error"]["message"])) project = None if response: info = response["project"] project = Project() project.setId(info["id"]) project.setName(info["name"]) project.setEnabled(info["enabled"]) return project
def getProjects(self, usr_id=None, name=None, domain_id=None): if usr_id: try: response = self.getResource("users/%s/projects" % usr_id, "GET") except requests.exceptions.HTTPError as ex: response = ex.response.json() message = response["error"]["message"] raise SynergyError("error on retrieving the users's projects " "(id=%r): %s" % (usr_id, message)) else: data = {} if domain_id: data["domain_id"] = domain_id if name: data["name"] = name try: response = self.getResource("/projects", "GET", data=data) except requests.exceptions.HTTPError as ex: response = ex.response.json() raise SynergyError( "error on retrieving the projects list: %s" % response["error"]["message"]) projects = [] if response: projects_info = response["projects"] for info in projects_info: project = Project() project.setId(info["id"]) project.setName(info["name"]) project.setEnabled(info["enabled"]) projects.append(project) return projects
def getProjects(self, usr_id=None, name=None, domain_id=None): if usr_id: try: response = self.getResource( "users/%s/projects" % usr_id, "GET") except requests.exceptions.HTTPError as ex: response = ex.response.json() message = response["error"]["message"] raise SynergyError("error on retrieving the users's projects " "(id=%r): %s" % (usr_id, message)) else: data = {} if domain_id: data["domain_id"] = domain_id if name: data["name"] = name try: response = self.getResource("/projects", "GET", data=data) except requests.exceptions.HTTPError as ex: response = ex.response.json() raise SynergyError("error on retrieving the projects list: %s" % response["error"]["message"]) projects = [] if response: projects_info = response["projects"] for info in projects_info: project = Project() project.setId(info["id"]) project.setName(info["name"]) project.setEnabled(info["enabled"]) projects.append(project) return projects