def addCapability(self, capability): ''' @param capability: either Activity object, or URI string ''' from SmartAPI.model.Activity import Activity if isinstance(capability, Activity): self.capabilities.append(capability) elif isinstance(capability, str): activity = Activity(capability) activity.clearTypes() self.capabilities.append(activity)
def create(cls, generatedBy): request = Request() if (generatedBy is None or generatedBy == ""): raise InsufficientDataException("Invalid smartapi:generatedBy URI.") g = Activity(generatedBy) g.clearTypes() request.setGeneratedBy(g) request.setGeneratedAt(datetime.datetime.now()) return request;
def create(self, generatedBy): notification = Notification() if (generatedBy is None or (generatedBy is not None and generatedBy == "")): raise InsufficientDataException("Invalid seas:generatedBy URI.") g = Activity(generatedBy) g.clearTypes() notification.setGeneratedBy(g) # timestamp of when this message is being generated (now) notification.setGeneratedAt(datetime.datetime.now()) return notification
def create(self, generatedBy): resp = Response() if (generatedBy is None or (generatedBy is not None and generatedBy == "")): raise InsufficientDataException("Invalid seas:generatedBy URI.") g = Activity(generatedBy) g.clearTypes() resp.setGeneratedBy(g) # timestamp of when this message is being generated (now) resp.setGeneratedAt(datetime.datetime.now()) resp.addType(RESOURCE.RESPONSE) return resp
def create(self, generatedBy): evaluation = Evaluation() if (generatedBy is None or (generatedBy is not None and generatedBy == "")): raise InsufficientDataException( "Invalid command generator id (seas:generatedBy) URI.") g = Activity(generatedBy) g.clearTypes() evaluation.setGeneratedBy(g) # timestamp of when this message is being generated (now) evaluation.setGeneratedAt(datetime.datetime.now()) evaluation.addType(RESOURCE.COMMAND) return evaluation