def create(collection_id): """Create a mapping. --- post: summary: Create a mapping parameters: - description: The collection id. in: path name: collection_id required: true schema: minimum: 1 type: integer example: 2 requestBody: content: application/json: schema: $ref: '#/components/schemas/MappingCreate' responses: '200': content: application/json: schema: $ref: '#/components/schemas/Mapping' description: OK tags: - Collection - Mapping """ collection = get_db_collection(collection_id, request.authz.WRITE) data = parse_request("MappingCreate") mapping = Mapping.create( load_query(), get_table_id(data), collection, request.authz.id, entityset_id=get_entityset_id(data), ) db.session.commit() return MappingSerializer.jsonify(mapping)
def create(collection_id): """Create a mapping. --- post: summary: Create a mapping parameters: - description: The collection id. in: path name: collection_id required: true schema: minimum: 1 type: integer example: 2 requestBody: content: application/json: schema: $ref: '#/components/schemas/MappingCreate' responses: '200': content: application/json: schema: $ref: '#/components/schemas/Mapping' description: OK tags: - Collection - Mapping """ collection = get_db_collection(collection_id, request.authz.WRITE) data = parse_request('MappingCreate') entity_id = data.get('table_id') query = load_query() entity = get_index_entity(entity_id, request.authz.READ) mapping = Mapping.create(query, entity.get('id'), collection, request.authz.id) # noqa return MappingSerializer.jsonify(mapping)