def delete(self, project_id, descriptor_id): """ Delete a metadata descriptor. --- description: Descriptors serve to describe extra fields listed in the data attribute of entities. tags: - Projects parameters: - in: path name: project_id required: true schema: type: UUID example: 5dc235ec-125e-4ba5-b1db-604d4babc315 - in: path name: descriptor_id required: true schema: type: UUID example: 5dc235ec-125e-4ba5-b1db-604d4babc315 responses: 204: description: Metadata descriptor deleted """ user_service.check_all_departments_access( project_id, projects_service.get_metadata_descriptor(descriptor_id) ["departments"], ) projects_service.remove_metadata_descriptor(descriptor_id) return "", 204
def get(self, project_id, descriptor_id): """ Get a metadata descriptor. --- description: Descriptors serve to describe extra fields listed in the data attribute of entities. tags: - Projects parameters: - in: path name: project_id required: true schema: type: UUID example: 5dc235ec-125e-4ba5-b1db-604d4babc315 - in: path name: descriptor_id required: true schema: type: UUID example: 5dc235ec-125e-4ba5-b1db-604d4babc315 responses: 200: description: Metadata descriptor """ user_service.check_project_access(project_id) return projects_service.get_metadata_descriptor(descriptor_id)
def put(self, project_id, descriptor_id): """ Update a metadata descriptor. --- description: Descriptors serve to describe extra fields listed in the data attribute of entities. tags: - Projects parameters: - in: path name: project_id required: true schema: type: UUID example: 5dc235ec-125e-4ba5-b1db-604d4babc315 - in: path name: descriptor_id required: true schema: type: UUID example: 5dc235ec-125e-4ba5-b1db-604d4babc315 responses: 200: description: Metadata descriptor updated """ args = self.get_args([ ("name", "", False), ("for_client", "False", False), ("choices", [], False, "append"), ("departments", [], False, "append"), ]) user_service.check_all_departments_access( project_id, projects_service.get_metadata_descriptor(descriptor_id) ["departments"] + args["departments"], ) if len(args["name"]) == 0: raise WrongParameterException("Name cannot be empty.") args["for_client"] = args["for_client"] == "True" return projects_service.update_metadata_descriptor(descriptor_id, args)
def get(self, project_id, descriptor_id): user_service.check_manager_project_access(project_id) return projects_service.get_metadata_descriptor(descriptor_id)