def CreateDataset(self, request, context): # validate request payload data = dataset_serializer.load(request) dataset = documents.Dataset(name=data['name'], description=data['description'], scope=data['scope'], project=data['project']).save() return dataset_serializer.dump(dataset)
def UpdateDataset(self, request, context): # validate request payload data = dataset_serializer.load(request) # validate id if not data.get('id'): raise InvalidArgument("Dataset's id not provided.") # retrieve dataset dataset = documents.Dataset.objects(deleted=False).get(id=data['id']) # update name and description. # other fields are immutable dataset.name = data['name'] dataset.description = data['description'] dataset.last_update = datetime.datetime.now() dataset.save() return dataset_serializer.dump(dataset)
def RetrieveDataset(self, request, context): data = id_serializer.load(request) dataset = documents.Dataset.objects(deleted=False).get(id=data['id']) return dataset_serializer.dump(dataset)