コード例 #1
0
def create_customer():
    try:
        customer = Customer.parse(request.json)
    except ValueError as e:
        raise ApiError(str(e), 400)

    try:
        customer = customer.create()
    except Exception as e:
        raise ApiError(str(e), 500)

    admin_audit_trail.send(current_app._get_current_object(),
                           event='customer-created',
                           message='',
                           user=g.login,
                           customers=g.customers,
                           scopes=g.scopes,
                           resource_id=customer.id,
                           type='customer',
                           request=request)

    if customer:
        return jsonify(status='ok',
                       id=customer.id,
                       customer=customer.serialize), 201
    else:
        raise ApiError('create customer lookup failed', 500)
コード例 #2
0
ファイル: customers.py プロジェクト: 3IWOH/alerta
def create_customer():
    try:
        customer = Customer.parse(request.json)
    except ValueError as e:
        raise ApiError(str(e), 400)

    try:
        customer = customer.create()
    except Exception as e:
        raise ApiError(str(e), 500)

    if customer:
        return jsonify(status="ok", id=customer.id, customer=customer.serialize), 201
    else:
        raise ApiError("create customer lookup failed", 500)
コード例 #3
0
def create_customer():
    try:
        customer = Customer.parse(request.json)
    except ValueError as e:
        raise ApiError(str(e), 400)

    try:
        customer = customer.create()
    except Exception as e:
        raise ApiError(str(e), 500)

    if customer:
        return jsonify(status="ok",
                       id=customer.id,
                       customer=customer.serialize), 201
    else:
        raise ApiError("create customer lookup failed", 500)
コード例 #4
0
ファイル: customers.py プロジェクト: guardian/alerta
def create_customer():
    try:
        customer = Customer.parse(request.json)
    except ValueError as e:
        raise ApiError(str(e), 400)

    try:
        customer = customer.create()
    except Exception as e:
        raise ApiError(str(e), 500)

    admin_audit_trail.send(current_app._get_current_object(), event='customer-created', message='', user=g.login,
                           customers=g.customers, scopes=g.scopes, resource_id=customer.id, type='customer', request=request)

    if customer:
        return jsonify(status='ok', id=customer.id, customer=customer.serialize), 201
    else:
        raise ApiError('create customer lookup failed', 500)