Beispiel #1
0
def list_group():
    if request.method == 'GET':
        try:
            groups = get_groups_list()
            status = 200
            response = {'group_list': groups}

        except Exception as e:
            log.error('Error in getting  group List -- {0}'.format(e))
            status = 500
            response = {'message': str(e)}
    else:
        try:

            groups = request.json['groups']
            group_list = get_groups_list()
            group_add = add_groups(groups)

            status = 200
            response = {'message': ' Groups Created'}
        except Exception as e:
            log.error('Error in creating  group List -- {0}'.format(e))
            status = 500
            response = {'message': str(e), 'groups_list': group_list}

    resp = Response(response=json.dumps(response),
                    status=status,
                    mimetype="application/json")
    return resp
Beispiel #2
0
def list_group():
    if request.method == 'GET':
        try:
            groups = get_groups_list()
            status = 200
            response = {
                'group_list': groups
            }

        except Exception as e:
            log.error('Error in getting  group List -- {0}'.format(e))
            status = 500
            response = {
                'message': str(e)
            }
    else:
        try:

            groups = request.json['groups']
            group_list = get_groups_list()
            group_add = add_groups(groups)

            status = 200
            response = {
                'message': ' Groups Created'
            }
        except Exception as e:
            log.error('Error in creating  group List -- {0}'.format(e))
            status = 500
            response = {
                'message': str(e),
                'groups_list': group_list
            }

    resp = Response(response=json.dumps(response),
                    status=status,
                    mimetype="application/json")
    return resp
Beispiel #3
0
def delete_group():
    try:
        group_name = request.json['groups'].lower()
        log.info(group_name)
        group_list = get_groups_list()

        group = delete_groups(group_name)
        status = 200
        response = {'message': ' Groups Deleted'}
    except Exception as e:
        log.error('Error in deleting  group List -- {0}'.format(e))
        status = 500
        response = {'message': str(e), 'groups_list': group_list}

    resp = Response(response=json.dumps(response),
                    status=status,
                    mimetype="application/json")
    return resp
Beispiel #4
0
def delete_group():
    try:
        group_name = request.json['groups'].lower()
        log.info(group_name)
        group_list = get_groups_list()

        group = delete_groups(group_name)
        status = 200
        response = {
            'message': ' Groups Deleted'
        }
    except Exception as e:
        log.error('Error in deleting  group List -- {0}'.format(e))
        status = 500
        response = {
            'message': str(e),
            'groups_list': group_list
        }

    resp = Response(response=json.dumps(response),
                    status=status,
                    mimetype="application/json")
    return resp