Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 def get(self, version):
     logging.debug("LevelsListHandler#get")
     
     if (self.valid_version(version)):
         
         self.json({"levels": Level.all()})
         
     else:
         
         self.error(404, "API Version %s not supported" % version)