def synchronize_resource(self, resource: Resource, response: Union[Exception, Dict], action_name: str, succeeded: bool, synchronized: bool) -> None: if succeeded: action = Action(action_name, succeeded, None) self.sync_metadata(resource, response) else: action = Action(action_name, succeeded, response) resource._last_action = action resource._synchronized = synchronized
def _validate_many(self, resources: List[Resource]) -> None: for resource in resources: conforms, graph, _ = self.service.validate(resource) if conforms: resource._validated = True action = Action(self._validate_many.__name__, conforms, None) else: resource._validated = False violations = set(" ".join(re.findall('[A-Z][^A-Z]*', as_term(o))) for o in graph.objects(None, SH.sourceConstraintComponent)) message = f"violation(s) of type(s) {', '.join(sorted(violations))}" action = Action(self._validate_many.__name__, conforms, ValidationError(message)) resource._last_action = action