Ejemplo n.º 1
0
    def post_all(self):
        """Create Blacklisted Zone"""
        request = pecan.request
        response = pecan.response
        context = request.environ['context']
        body = request.body_dict

        blacklist = DesignateAdapter.parse('API_v2', body, Blacklist())

        blacklist.validate()

        # Create the blacklist
        blacklist = self.central_api.create_blacklist(
            context, blacklist)

        LOG.info("Created %(blacklist)s", {'blacklist': blacklist})

        response.status_int = 201

        blacklist = DesignateAdapter.render(
            'API_v2', blacklist, request=request)

        response.headers['Location'] = blacklist['links']['self']

        # Prepare and return the response body
        return blacklist
Ejemplo n.º 2
0
    def post_all(self):
        """ Create Blacklisted Zone """
        request = pecan.request
        response = pecan.response
        context = request.environ['context']

        body = request.body_dict

        # Validate the request conforms to the schema
        self._resource_schema.validate(body)

        # Convert from APIv2 -> Central format
        values = self._view.load(context, request, body)

        # Create the blacklist
        blacklist = self.central_api.create_blacklist(
            context, Blacklist(**values))

        response.status_int = 201

        response.headers['Location'] = self._view._get_resource_href(
            request, blacklist)

        # Prepare and return the response body
        return self._view.show(context, request, blacklist)