code: def RegisterArtifact(self,
                         artifact_rdfvalue,
                         source="datastore",
                         overwrite_if_exists=False,
                         overwrite_system_artifacts=False):
      
      artifact_name = artifact_rdfvalue.name
      if artifact_name in self._artifacts:
        if not overwrite_if_exists:
          details = "artifact already exists and `overwrite_if_exists` is unset"
          raise rdf_artifacts.ArtifactDefinitionError(artifact_name, details)
        elif not overwrite_system_artifacts:
          artifact_obj = self._artifacts[artifact_name]
          if not artifact_obj.loaded_from.startswith("datastore:"):
            # This artifact was not uploaded to the datastore but came from a
            # file, refuse to overwrite.
            details = "system artifact cannot be overwritten"
            raise rdf_artifacts.ArtifactDefinitionError(artifact_name, details)
  
      # Preserve where the artifact was loaded from to help debugging.
      artifact_rdfvalue.loaded_from = source
      # Clear any stale errors.
      artifact_rdfvalue.error_message = None
      self._artifacts[artifact_rdfvalue.name] = artifact_rdfvalue
docs: Registers a new artifact.