Пример #1
0
    def post_all(self):
        """Create TsigKey"""
        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 tsigkey
        tsigkey = self.central_api.create_tsigkey(
            context, TsigKey(**values))

        response.status_int = 201

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

        # Prepare and return the response body
        return self._view.show(context, request, tsigkey)
Пример #2
0
def create_tsigkey():
    context = flask.request.environ.get('context')
    values = flask.request.json

    tsigkey_schema.validate(values)
    tsigkey = get_central_api().create_tsigkey(context,
                                               tsigkey=TsigKey(**values))

    response = flask.jsonify(tsigkey_schema.filter(tsigkey))
    response.status_int = 201
    response.location = flask.url_for('.get_tsigkey', tsigkey_id=tsigkey['id'])

    return response
Пример #3
0
    def post_all(self):
        """Create TsigKey"""
        request = pecan.request
        response = pecan.response
        context = request.environ['context']
        body = request.body_dict

        tsigkey = DesignateAdapter.parse('API_v2', body, TsigKey())

        tsigkey.validate()

        # Create the tsigkey
        tsigkey = self.central_api.create_tsigkey(context, tsigkey)

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

        response.headers['Location'] = tsigkey['links']['self']
        response.status_int = 201
        # Prepare and return the response body
        return tsigkey
Пример #4
0
def create_tsigkey():
    context = flask.request.environ.get('context')
    values = flask.request.json

    central_api = central_rpcapi.CentralAPI.get_instance()

    tsigkey_schema.validate(values)

    tsigkey = TsigKey.from_dict(values)

    # The V1 API only deals with the default pool, so we restrict the view
    # of TSIG Keys to those scoped to the default pool.
    tsigkey.scope = 'POOL'
    tsigkey.resource_id = default_pool_id

    tsigkey = central_api.create_tsigkey(context, tsigkey)

    response = flask.jsonify(tsigkey_schema.filter(tsigkey))
    response.status_int = 201
    response.location = flask.url_for('.get_tsigkey', tsigkey_id=tsigkey['id'])

    return response
Пример #5
0
def create_tsigkey():
    context = flask.request.environ.get('context')
    values = flask.request.json

    central_api = central_rpcapi.CentralAPI.get_instance()

    tsigkey_schema.validate(values)

    tsigkey = TsigKey.from_dict(values)

    # The V1 API only deals with the default pool, so we restrict the view
    # of TSIG Keys to those scoped to the default pool.
    tsigkey.scope = 'POOL'
    tsigkey.resource_id = default_pool_id

    tsigkey = central_api.create_tsigkey(context, tsigkey)

    response = flask.jsonify(tsigkey_schema.filter(tsigkey))
    response.status_int = 201
    response.location = flask.url_for('.get_tsigkey', tsigkey_id=tsigkey['id'])

    return response