def product_get()

in cqrs/services/product/main.py [0:0]


def product_get():
    json_data = request.get_json()
    product_id = None
    invalid_fields = []
    for key in json_data.keys():
        if key == 'product_id':
            product_id = json_data[key]
        else:
            invalid_fields.append(key)
    if product_id is None:
        return error500()

    query = ds_client.query(kind='ProductCQRS')
    query.add_filter('product_id', '=', product_id)
    resp = None
    for result in query.fetch(): # This should return a single entity.
        resp = {
            'product_id': result['product_id'],
            'product_name': result['product_name'],
            'unit_price': result['unit_price'],
        }
        break
    if resp is None:
        return error500()

    return resp, 200