Exemple #1
0
    def post_all(self):
        """Create Tld"""
        request = pecan.request
        response = pecan.response
        context = request.environ['context']
        body = request.body_dict

        tld = DesignateAdapter.parse('API_v2', body, Tld())

        tld.validate()

        # Create the tld
        tld = self.central_api.create_tld(context, tld)
        response.status_int = 201

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

        response.headers['Location'] = tld['links']['self']
        # Prepare and return the response body
        return tld
Exemple #2
0
    def post_all(self):
        """ Create Tld """
        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 tld
        tld = self.central_api.create_tld(context, Tld(**values))
        response.status_int = 201

        response.headers['Location'] = self._view._get_resource_href(
            request, tld)
        # Prepare and return the response body
        return self._view.show(context, request, tld)