示例#1
0
def get_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if Scope.admin in g.scopes or Scope.admin_customers in g.scopes or customer.customer in g.customers:
        return jsonify(status='ok', total=1, customer=customer.serialize)
    else:
        raise ApiError('not found', 404)
示例#2
0
文件: customers.py 项目: yrsdi/alerta
def get_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if customer:
        return jsonify(status='ok', total=1, customer=customer.serialize)
    else:
        raise ApiError('not found', 404)
示例#3
0
def get_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if Scope.admin in g.scopes or Scope.admin_customers in g.scopes or customer.customer in g.customers:
        return jsonify(status='ok', total=1, customer=customer.serialize)
    else:
        raise ApiError('not found', 404)
示例#4
0
def delete_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError("not found", 404)

    if customer.delete():
        return jsonify(status="ok")
    else:
        raise ApiError("failed to delete customer", 500)
示例#5
0
文件: customers.py 项目: 3IWOH/alerta
def delete_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError("not found", 404)

    if customer.delete():
        return jsonify(status="ok")
    else:
        raise ApiError("failed to delete customer", 500)
示例#6
0
def delete_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError('not found', 404)

    if customer.delete():
        return jsonify(status='ok')
    else:
        raise ApiError('failed to delete customer', 500)
示例#7
0
文件: customers.py 项目: yrsdi/alerta
def delete_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError('not found', 404)

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

    if customer.delete():
        return jsonify(status='ok')
    else:
        raise ApiError('failed to delete customer', 500)
示例#8
0
def delete_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError('not found', 404)

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

    if customer.delete():
        return jsonify(status='ok')
    else:
        raise ApiError('failed to delete customer', 500)
示例#9
0
def update_customer(customer_id):
    if not request.json:
        raise ApiError('nothing to change', 400)

    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError('not found', 404)

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

    if customer.update(**request.json):
        return jsonify(status='ok')
    else:
        raise ApiError('failed to update customer', 500)