def post(self, version, status_slug): if (self.valid_version(version)): status = Status.get_by_slug(status_slug) if status: name = self.request.get('name', default_value=None) image = self.request.get('image', default_value=None) description = self.request.get('description', default_value=None) level = self.request.get('level', default_value=None) severity = Level.get_severity(level) if description: status.description = description if image: status.image = image if name: status.name = name if severity: status.severity = severity if description or name or image or severity: status.put() self.json(status.rest(self.base_url(version))) else: self.error(404, "Status %s not found" % status_slug) else: self.error(404, "API Version %s not supported" % version)
def post(self, version): if (self.valid_version(version)): name = self.request.get('name', default_value=None) description = self.request.get('description', default_value=None) image = self.request.get('image', default_value=None) level = self.request.get('level', default_value=None) severity = Level.get_severity(level) if name and description and severity and image: slug = slugify.slugify(name) status = Status.get_by_slug(slug) # Update existing resource if status: status.description = description status.severity = severity status.image = image status.name = name status.put() self.json(status.rest(self.base_url(version))) # Create new service else: status = Status(name=name, slug=slug, description=description, severity=severity, image=image) status.put() self.json(status.rest(self.base_url(version))) else: self.error(400, "Bad Data") else: self.error(404, "API Version %s not supported" % version)
def get(self, version, status_slug): logging.debug("CurrentStatusHandler#get") if (self.valid_version(version)): status = Status.get_by_slug(status_slug) if (status): self.json(status.rest(self.base_url(version))) else: self.error(404, "No status %s for Service %s" % status_slug) else: self.error(404, "API Version %s not supported" % version)
def delete(self, version, status_slug): logging.debug("StatusInstanceHandler#delete slug=%s" % status_slug) if (self.valid_version(version)): status = Status.get_by_slug(status_slug) if status: # We may want to think more about this events = Event.all().filter('status =', status).fetch(1000) for event in events: event.delete() status.delete() self.json(status.rest(self.base_url(version))) else: self.error(404, "Status %s not found" % service_slug) else: self.error(404, "API Version %s not supported" % version)
def post(self, version, service_slug): logging.debug("EventsListHandler#post") if (self.valid_version(version)): status_slug = self.request.get("status", default_value=None) message = self.request.get("message", default_value=None) informational = self.request.get("informational", default_value=None) if message: service = Service.get_by_slug(service_slug) if service: if not status_slug: event = service.current_event() if event: status = event.status else: status = Status.default() else: status = Status.get_by_slug(status_slug) if status: e = Event(status=status, service=service, message=message) e.informational = informational and informational == "true" e.put() self.json(e.rest(self.base_url(version))) else: self.error(404, "Status %s not found" % status_slug) else: self.error(404, "Service %s not found" % service_slug) else: self.error(400, "Event message is required") else: self.error(404, "API Version %s not supported" % version)