Ejemplo n.º 1
0
def api_package_list(pattern=None):
    '''
List packages
-------------
    List packages based on a pattern. If no pattern is provided, return all
    the package.

    ::

        /api/packages/<pattern>/

        /api/packages/?pattern=<pattern>

    Accept GET queries only

    :arg pattern: Pattern to list packages from their name.
    :arg branches: List of string of the branches name in which these
        packages will be searched.
    :arg poc: String of the user name to to which restrict the search.
    :arg orphaned: Boolean to retrict the search to orphaned packages.
    :arg critpath: Boolean to retrict the search to critpath packages.
        Defaults to None which means results include both critpath and
        non-critpath packages.
    :arg status: Allows to filter packages based on their status: Approved,
        Orphaned, Retired, Removed.
    :arg acls: Boolean use to retrieve the acls in addition of the package
        information. Beware that this may reduce significantly the response
        time, it is advise to use it in combinaition with a specifir branch.
        Defaults to False.
    :kwarg eol: a boolean to specify whether to include results for
        EOL collections or not. Defaults to False.
        If True, it will return results for all collections (including EOL).
        If False, it will return results only for non-EOL collections.
    :kwarg limit: An integer to limit the number of results, defaults to
        250, maximum is 500.
    :kwarg page: The page number to return (useful in combination to limit).
    :kwarg count: A boolean to return the number of packages instead of the
        list. Defaults to False.

    *Results are paginated*

    Sample response:

    ::

        /api/packages/guak*

        {
          "output": "ok",
          "packages": [
            {
              "status": "Approved",
              "upstream_url": null,
              "description": "Guake is a drop-down terminal for Gnome "
                             "Desktop Environment, so you just need to "
                             "press a key to invoke him,and press again"
                             " to hide."
              "summary": "Drop-down terminal for GNOME",
               "creation_date": 1384775354.0,
                "review_url": null,
                "name": "guake"
            }
          ],
          "page_total": 1,
          "page": 1
        }

        /api/packages/cl*?status=Orphaned&branches=f20&acls=true

        {
          "output": "ok",
          "packages": [
            {
              "status": "Approved",
              "upstream_url": null,
              "description": "clive is a video extraction tool for "
                             "user-uploaded video hosts such as Youtube,"
                             "Google Video, Dailymotion, Guba, Metacafe "
                             "and Sevenload.It can be chained with 3rd "
                             "party tools for subsequent video re-encoding"
                             " and and playing.",
              "summary": "Video extraction tool for user-uploaded video hosts",
              "acls": [
                {
                  "status": "Retired",
                  "point_of_contact": "orphan",
                  "status_change": 1385363055.0,
                  "collection": {
                    "status": "Active",
                    "branchname": "f20",
                    "version": "20",
                    "name": "Fedora"
                  },
                  "package": null
                }
              ],
              "creation_date": 1385361948.0,
              "review_url": null,
              "name": "clive"
            }
          ],
          "page_total": 1,
          "page": 1
        }

    .. note:: the ``status_change`` and ``create_date`` fields are both
            timestamps expressed in
            `Unix TIME <https://en.wikipedia.org/wiki/Unix_time>`_

    '''
    httpcode = 200
    output = {}

    pattern = flask.request.args.get('pattern', pattern) or '*'
    branches = flask.request.args.getlist('branches', None)
    poc = flask.request.args.get('poc', None)
    orphaned = flask.request.args.get('orphaned', None)
    if str(orphaned).lower() in ['0', 'false']:
        orphaned = False
    elif orphaned is not None:
        orphaned = bool(orphaned)

    critpath = flask.request.args.get('critpath', None)
    if critpath and str(critpath).lower() in ['0', 'false']:
        critpath = False
    elif critpath:
        critpath = True
    acls = bool(flask.request.args.get('acls', False))
    statuses = flask.request.args.getlist('status', None)
    eol = flask.request.args.get('eol', False)
    page = flask.request.args.get('page', 1)
    limit = get_limit()
    count = flask.request.args.get('count', False)
    try:
        if not branches:
            branches = [None]
        if not statuses:
            statuses = [None]

        if count:
            packages = 0
            for status, branch in itertools.product(
                    statuses, branches):
                packages += pkgdblib.search_package(
                    SESSION,
                    pkg_name=pattern,
                    pkg_branch=branch,
                    pkg_poc=poc,
                    orphaned=orphaned,
                    critpath=critpath,
                    status=status,
                    eol=eol,
                    page=page,
                    limit=limit,
                    count=count,
                )

            output['output'] = 'ok'
            output['packages'] = packages
            output['page'] = 1
            output['page_total'] = 1
        else:
            packages = set()
            packages_count = 0
            for status, branch in itertools.product(
                    statuses, branches):
                packages.update(
                    pkgdblib.search_package(
                        SESSION,
                        pkg_name=pattern,
                        pkg_branch=branch,
                        pkg_poc=poc,
                        orphaned=orphaned,
                        critpath=critpath,
                        status=status,
                        eol=eol,
                        page=page,
                        limit=limit,
                        count=count,
                    )
                )
                packages_count += pkgdblib.search_package(
                    SESSION,
                    pkg_name=pattern,
                    pkg_branch=branch,
                    pkg_poc=poc,
                    orphaned=orphaned,
                    critpath=critpath,
                    status=status,
                    eol=eol,
                    page=page,
                    limit=limit,
                    count=True,
                )

            if not packages:
                output['output'] = 'notok'
                output['packages'] = []
                output['error'] = 'No packages found for these parameters'
                httpcode = 404
            else:
                output['packages'] = [
                    pkg.to_json(acls=acls, collection=branches, package=False)
                    for pkg in packages
                ]
                output['output'] = 'ok'
                output['page'] = int(page)
                output['page_total'] = int(ceil(packages_count / float(limit)))

    except pkgdblib.PkgdbException, err:
        SESSION.rollback()
        output['output'] = 'notok'
        output['error'] = str(err)
        httpcode = 500
Ejemplo n.º 2
0
def api_package_list(pattern=None):
    '''
    List packages
    -------------
    List packages based on a pattern. If no pattern is provided, return all
    the package.

    ::

        /api/packages/<pattern>/

        /api/packages/?pattern=<pattern>

    Accepts GET queries only

    :arg pattern: Pattern to list packages from their name.
    :arg branches: List of string of the branches name in which these
        packages will be searched.
    :arg poc: String of the user name to to which restrict the search.
    :arg orphaned: Boolean to retrict the search to orphaned packages.
    :arg critpath: Boolean to retrict the search to critpath packages.
        Defaults to None which means results include both critpath and
        non-critpath packages.
    :arg status: Allows to filter packages based on their status: Approved,
        Orphaned, Retired, Removed.
    :arg acls: Boolean use to retrieve the acls in addition of the package
        information. Beware that this may reduce significantly the response
        time, it is advise to use it in combinaition with a specifir branch.
        Defaults to False.
    :kwarg eol: a boolean to specify whether to include results for
        EOL collections or not. Defaults to False.
        If True, it will return results for all collections (including EOL).
        If False, it will return results only for non-EOL collections.
    :kwarg limit: An integer to limit the number of results, defaults to
        250, maximum is 500.
    :kwarg page: The page number to return (useful in combination to limit).
    :kwarg count: A boolean to return the number of packages instead of the
        list. Defaults to False.

    *Results are paginated*

    Sample response:

    ::

        /api/packages/guak*

        {
          "output": "ok",
          "packages": [
            {
              "status": "Approved",
              "upstream_url": null,
              "description": "Guake is a drop-down terminal for Gnome "
                             "Desktop Environment, so you just need to "
                             "press a key to invoke him,and press again"
                             " to hide."
              "summary": "Drop-down terminal for GNOME",
               "creation_date": 1384775354.0,
                "review_url": null,
                "name": "guake"
            }
          ],
          "page_total": 1,
          "page": 1
        }

        /api/packages/cl*?status=Orphaned&branches=f20&acls=true

        {
          "output": "ok",
          "packages": [
            {
              "status": "Approved",
              "upstream_url": null,
              "description": "clive is a video extraction tool for "
                             "user-uploaded video hosts such as Youtube,"
                             "Google Video, Dailymotion, Guba, Metacafe "
                             "and Sevenload.It can be chained with 3rd "
                             "party tools for subsequent video re-encoding"
                             " and and playing.",
              "summary": "Video extraction tool for user-uploaded video hosts",
              "acls": [
                {
                  "status": "Retired",
                  "point_of_contact": "orphan",
                  "status_change": 1385363055.0,
                  "collection": {
                    "status": "Active",
                    "branchname": "f20",
                    "version": "20",
                    "name": "Fedora"
                  },
                  "package": null
                }
              ],
              "creation_date": 1385361948.0,
              "review_url": null,
              "name": "clive"
            }
          ],
          "page_total": 1,
          "page": 1
        }

    .. note:: the ``status_change`` and ``create_date`` fields are both
            timestamps expressed in
            `Unix TIME <https://en.wikipedia.org/wiki/Unix_time>`_

    '''
    httpcode = 200
    output = {}

    pattern = flask.request.args.get('pattern', pattern) or '*'
    branches = flask.request.args.getlist('branches', None)
    poc = flask.request.args.get('poc', None)
    orphaned = flask.request.args.get('orphaned', None)
    if str(orphaned).lower() in ['0', 'false']:
        orphaned = False
    elif orphaned is not None:
        orphaned = bool(orphaned)

    critpath = flask.request.args.get('critpath', None)
    if critpath and str(critpath).lower() in ['0', 'false']:
        critpath = False
    elif critpath:
        critpath = True
    acls = bool(flask.request.args.get('acls', False))
    statuses = flask.request.args.getlist('status', None)
    eol = flask.request.args.get('eol', False)
    page = flask.request.args.get('page', 1)
    limit = get_limit()
    count = flask.request.args.get('count', False)
    try:
        if not branches:
            branches = [None]
        if not statuses:
            statuses = [None]

        if count:
            packages = 0
            for status, branch in itertools.product(statuses, branches):
                packages += pkgdblib.search_package(
                    SESSION,
                    pkg_name=pattern,
                    pkg_branch=branch,
                    pkg_poc=poc,
                    orphaned=orphaned,
                    critpath=critpath,
                    status=status,
                    eol=eol,
                    page=page,
                    limit=limit,
                    count=count,
                )

            output['output'] = 'ok'
            output['packages'] = packages
            output['page'] = 1
            output['page_total'] = 1
        else:
            packages = set()
            packages_count = 0
            for status, branch in itertools.product(statuses, branches):
                packages.update(
                    pkgdblib.search_package(
                        SESSION,
                        pkg_name=pattern,
                        pkg_branch=branch,
                        pkg_poc=poc,
                        orphaned=orphaned,
                        critpath=critpath,
                        status=status,
                        eol=eol,
                        page=page,
                        limit=limit,
                        count=count,
                    ))
                packages_count += pkgdblib.search_package(
                    SESSION,
                    pkg_name=pattern,
                    pkg_branch=branch,
                    pkg_poc=poc,
                    orphaned=orphaned,
                    critpath=critpath,
                    status=status,
                    eol=eol,
                    page=page,
                    limit=limit,
                    count=True,
                )

            if not packages:
                output['output'] = 'notok'
                output['packages'] = []
                output['error'] = 'No packages found for these parameters'
                httpcode = 404
            else:
                output['packages'] = [
                    pkg.to_json(acls=acls, collection=branches, package=False)
                    for pkg in packages
                ]
                output['output'] = 'ok'
                output['page'] = int(page)
                output['page_total'] = int(ceil(packages_count / float(limit)))

    except pkgdblib.PkgdbException, err:
        SESSION.rollback()
        output['output'] = 'notok'
        output['error'] = str(err)
        httpcode = 500
Ejemplo n.º 3
0
def api_admin_actions():
    """
List admin actions
------------------
    List actions requiring intervention from an admin.

    ::

        /api/admin/actions/

    Accept GET queries only.

    :kwarg package: restrict the actions to a specific package.
    :kwarg packager: restrict the actions to a specific packager.
    :kwarg action: restrict the actions to a specific action, options are:
        ``request.branch``, ``request.package`` and ``request.unretire``.
    :kwarg status: restrict the actions depending on their status, options
        are: ``Awaiting Review``, ``Approved``, ``Denied``, ``Obsolete``,
        ``Removed``.
    :kwarg limit: An integer to limit the number of results, defaults to
        250, maximum is 500.
    :kwarg page: The page number to return (useful in combination to limit).

    Sample response:

    ::

        /api/admin/actions

        {
          "output": "ok",
          "actions": [
            {
              "action": "request.branch",
              "collection": {
                "branchname": "epel7",
                "dist_tag": ".el7",
                "koji_name": "epel7",
                "name": "Fedora EPEL",
                "status": "Active",
                "version": "7"
              },
              "date_created": 1402470695.0,
              "date_updated": 1402470695.0,
              "from_collection": {
                "branchname": "f19",
                "dist_tag": ".fc19",
                "koji_name": "f19",
                "name": "Fedora",
                "status": "Active",
                "version": "19"
              },
              "id": 8,
              "info": null,
              "package": {
                "acls": [],
                "creation_date": 1400063778.0,
                "description": "Guake is a drop-down terminal for Gnome "
                               "Desktop Environment, so you just need to "
                               "press a key to invoke him, and press again "
                               "to hide.",
                "name": "guake",
                "review_url": null,
                "status": "Approved",
                "summary": "Drop-down terminal for GNOME",
                "upstream_url": "http://guake.org/"
              },
              "status": "Awaiting Review",
              "user": "******"
            }
          ],
          "page": 1,
          "page_total": 1
        }

    .. note:: the ``date_created`` and ``date_updated`` fields are both
            timestamps expressed in
            `Unix TIME <https://en.wikipedia.org/wiki/Unix_time>`_

    """
    package = flask.request.args.get('package', None)
    packager = flask.request.args.get('packager', None)
    action = flask.request.args.get('action', None)
    status = flask.request.args.get('status', None)
    page = flask.request.args.get('page', 1)
    limit = get_limit()

    httpcode = 200
    output = {}

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            limit=limit,
            page=page
        )

        cnt_actions += pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            count=True,
        )
    except PkgdbException as err:  # pragma: no cover
        SESSION.rollback()
        output['output'] = 'notok'
        output['error'] = str(err)
        httpcode = 500

    if not actions:
        output['output'] = 'notok'
        output['actions'] = []
        output['error'] = 'No actions found for these parameters'
        httpcode = 404
    else:
        output['actions'] = [
            act.to_json()
            for act in actions
        ]
        output['output'] = 'ok'
        output['page'] = int(page)
        output['page_total'] = int(ceil(cnt_actions / float(limit)))

    if 'page_total' not in output:
        output['page'] = 1
        output['page_total'] = 1

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
Ejemplo n.º 4
0
def api_packager_acl(packagername=None):
    '''
    User's ACL
    ----------
    List the ACLs of the user.

    ::

        /api/packager/acl/<fas_username>/

        /api/packager/acl/?packagername=<username>

    Accepts GET queries only.

    :arg packagername: String of the packager name.
    :kwarg acls: One or more ACL to filter the ACLs retrieved. Options are:
        ``approveacls``, ``commit``, ``watchbugzilla``, ``watchcommits``.
    :kwarg eol: a boolean to specify whether to include results for
        EOL collections or not. Defaults to False.
        If ``True``, it will return results for all collections (including
        EOL).
        If ``False``, it will return results only for non-EOL collections.
    :kwarg poc: a boolean specifying whether the results should be
        restricted to ACL for which the provided packager is the point
        of contact or not. Defaults to None.
        If ``True`` it will only return ACLs for packages on which the
        provided packager is point of contact.
        If ``False`` it will only return ACLs for packages on which the
        provided packager is not the point of contact.
        If ``None`` it will not filter the ACLs returned based on the point
        of contact of the package (thus every packages is returned).
    :kwarg page: The page number to return (useful in combination to limit).
    :kwarg limit: An integer to limit the number of results, defaults to
        250, maximum is 500 (acls).
    :kwarg count: A boolean to return the number of packages instead of the
        list. Defaults to False.

    *Results are paginated*

    Sample response:

    ::

        /api/packager/acl/pingou

        {
          "output": "ok",
          "page": 1,
          "page_total": 12
          "acls": [
            {
              "status": "Approved",
              "fas_name": "pingou",
              "packagelist": {
                "point_of_contact": "pingou",
                "critpath": False,
                "collection": {
                  "status": "EOL",
                  "branchname": "f16",
                  "version": "16",
                  "name": "Fedora"
                },
                "package": {
                  "status": "Approved",
                  "upstream_url": null,
                  "description": null,
                  "summary": "Data of T- and B-cell Acute Lymphocytic "
                             "Leukemia",
                  "creation_date": 1384775354.0,
                  "review_url": null,
                  "name": "R-ALL"
                }
              },
              "acl": "watchcommits"
            },
            {
              "status": "Approved",
              "fas_name": "pingou",
              "packagelist": {
                "point_of_contact": "pingou",
                "critpath": False,
                "collection": {
                  "status": "EOL",
                  "branchname": "f16",
                  "version": "16",
                  "name": "Fedora"
                },
                "package": {
                  "status": "Approved",
                  "upstream_url": null,
                  "description": null,
                  "summary": "Data of T- and B-cell Acute Lymphocytic "
                             "Leukemia",
                  "creation_date": 1384775354.0,
                  "review_url": null,
                  "name": "R-ALL"
                }
              },
              "acl": "watchbugzilla"
            }
          ]
        }

        /api/packager/acl/?packagername=random

        {
          "output": "notok",
          "error": "No ACL found for this user",
          "page": 1
        }

    '''
    httpcode = 200
    output = {}

    packagername = flask.request.args.get('packagername', None) or packagername
    acls = flask.request.args.getlist('acls', None)
    eol = flask.request.args.get('eol', False)
    poc = flask.request.args.get('poc', None)
    if poc is not None:
        if poc in ['False', '0', 0]:
            poc = False
        poc = bool(poc)

    pkg_acl = pkgdblib.get_status(SESSION, 'pkg_acl')['pkg_acl']
    for acl in acls:
        if acl not in pkg_acl:
            output = {
                'output': 'notok',
                'error': 'Invalid request, "%s" is an invalid acl' % acl
            }
            httpcode = 500
            jsonout = flask.jsonify(output)
            jsonout.status_code = httpcode
            return jsonout

    page = flask.request.args.get('page', 1)
    limit = get_limit()
    count = flask.request.args.get('count', False)

    if packagername:
        packagers = pkgdblib.get_acl_packager(SESSION,
                                              packager=packagername,
                                              acls=acls,
                                              eol=eol,
                                              poc=poc,
                                              page=page,
                                              limit=limit,
                                              count=count)
        if packagers:
            output['output'] = 'ok'
            if count:
                output['acls_count'] = packagers
            else:
                tmp = []
                for pkg in packagers:
                    dic = pkg[0].to_json(pkglist=False)
                    dic['packagelist'] = pkg[1].to_json(acls=False)
                    tmp.append(dic)
                output['acls'] = tmp

            total_acl = pkgdblib.get_acl_packager(SESSION,
                                                  packager=packagername,
                                                  acls=acls,
                                                  eol=eol,
                                                  poc=poc,
                                                  count=True)

            if count:
                output['page_total'] = 1
            else:
                output['page_total'] = int(ceil(total_acl / float(limit)))
        else:
            output = {'output': 'notok', 'error': 'No ACL found for this user'}
            httpcode = 404
    else:
        output = {'output': 'notok', 'error': 'Invalid request'}
        httpcode = 500

    output['page'] = page
    if 'page_total' not in output:
        output['page_total'] = 1

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
Ejemplo n.º 5
0
def api_packager_acl(packagername=None):
    '''
User's ACL
----------
    List the ACLs of the user.

    ::

        /api/packager/acl/<fas_username>/

        /api/packager/acl/?packagername=<username>

    Accept GET queries only.

    :arg packagername: String of the packager name.
    :kwarg acls: One or more ACL to filter the ACLs retrieved. Options are:
        ``approveacls``, ``commit``, ``watchbugzilla``, ``watchcommits``.
    :kwarg eol: a boolean to specify whether to include results for
        EOL collections or not. Defaults to False.
        If ``True``, it will return results for all collections (including
        EOL).
        If ``False``, it will return results only for non-EOL collections.
    :kwarg poc: a boolean specifying whether the results should be
        restricted to ACL for which the provided packager is the point
        of contact or not. Defaults to None.
        If ``True`` it will only return ACLs for packages on which the
        provided packager is point of contact.
        If ``False`` it will only return ACLs for packages on which the
        provided packager is not the point of contact.
        If ``None`` it will not filter the ACLs returned based on the point
        of contact of the package (thus every packages is returned).
    :kwarg page: The page number to return (useful in combination to limit).
    :kwarg limit: An integer to limit the number of results, defaults to
        250, maximum is 500 (acls).
    :kwarg count: A boolean to return the number of packages instead of the
        list. Defaults to False.

    *Results are paginated*

    Sample response:

    ::

        /api/packager/acl/pingou

        {
          "output": "ok",
          "page": 1,
          "page_total": 12
          "acls": [
            {
              "status": "Approved",
              "fas_name": "pingou",
              "packagelist": {
                "point_of_contact": "pingou",
                "critpath": False,
                "collection": {
                  "status": "EOL",
                  "branchname": "f16",
                  "version": "16",
                  "name": "Fedora"
                },
                "package": {
                  "status": "Approved",
                  "upstream_url": null,
                  "description": null,
                  "summary": "Data of T- and B-cell Acute Lymphocytic "
                             "Leukemia",
                  "creation_date": 1384775354.0,
                  "review_url": null,
                  "name": "R-ALL"
                }
              },
              "acl": "watchcommits"
            },
            {
              "status": "Approved",
              "fas_name": "pingou",
              "packagelist": {
                "point_of_contact": "pingou",
                "critpath": False,
                "collection": {
                  "status": "EOL",
                  "branchname": "f16",
                  "version": "16",
                  "name": "Fedora"
                },
                "package": {
                  "status": "Approved",
                  "upstream_url": null,
                  "description": null,
                  "summary": "Data of T- and B-cell Acute Lymphocytic "
                             "Leukemia",
                  "creation_date": 1384775354.0,
                  "review_url": null,
                  "name": "R-ALL"
                }
              },
              "acl": "watchbugzilla"
            }
          ]
        }

        /api/packager/acl/?packagername=random

        {
          "output": "notok",
          "error": "No ACL found for this user",
          "page": 1
        }

    '''
    httpcode = 200
    output = {}

    packagername = flask.request.args.get('packagername', None) or packagername
    acls = flask.request.args.getlist('acls', None)
    eol = flask.request.args.get('eol', False)
    poc = flask.request.args.get('poc', None)
    if poc is not None:
        if poc in ['False', '0', 0]:
            poc = False
        poc = bool(poc)

    pkg_acl = pkgdblib.get_status(SESSION, 'pkg_acl')['pkg_acl']
    for acl in acls:
        if acl not in pkg_acl:
            output = {
                'output': 'notok',
                'error': 'Invalid request, "%s" is an invalid acl' % acl}
            httpcode = 500
            jsonout = flask.jsonify(output)
            jsonout.status_code = httpcode
            return jsonout

    page = flask.request.args.get('page', 1)
    limit = get_limit()
    count = flask.request.args.get('count', False)

    if packagername:
        packagers = pkgdblib.get_acl_packager(
            SESSION,
            packager=packagername,
            acls=acls,
            eol=eol,
            poc=poc,
            page=page,
            limit=limit,
            count=count)
        if packagers:
            output['output'] = 'ok'
            if count:
                output['acls_count'] = packagers
            else:
                output['acls'] = [pkg.to_json() for pkg in packagers]

            total_acl = pkgdblib.get_acl_packager(
                SESSION,
                packager=packagername,
                acls=acls,
                eol=eol,
                poc=poc,
                count=True)

            if count:
                output['page_total'] = 1
            else:
                output['page_total'] = int(ceil(total_acl / float(limit)))
        else:
            output = {'output': 'notok', 'error': 'No ACL found for this user'}
            httpcode = 404
    else:
        output = {'output': 'notok', 'error': 'Invalid request'}
        httpcode = 500

    output['page'] = page
    if 'page_total' not in output:
        output['page_total'] = 1

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
Ejemplo n.º 6
0
def api_admin_actions():
    """
List admin actions
------------------
    List actions requiring intervention from an admin.

    ::

        /api/admin/actions/

    Accept GET queries only.

    :kwarg package: restrict the actions to a specific package.
    :kwarg packager: restrict the actions to a specific packager.
    :kwarg action: restrict the actions to a specific action, options are:
        ``request.branch``, ``request.package``.
    :kwarg status: restrict the actions depending on their status, options
        are: ``Awaiting Review``, ``Approved``, ``Denied``, ``Obsolete``,
        ``Removed``.
    :kwarg limit: An integer to limit the number of results, defaults to
        250, maximum is 500.
    :kwarg page: The page number to return (useful in combination to limit).

    Sample response:

    ::

        /api/admin/actions

        {
          "output": "ok",
          "actions": [
            {
              "action": "request.branch",
              "collection": {
                "branchname": "epel7",
                "dist_tag": ".el7",
                "koji_name": "epel7",
                "name": "Fedora EPEL",
                "status": "Active",
                "version": "7"
              },
              "date_created": 1402470695.0,
              "date_updated": 1402470695.0,
              "from_collection": {
                "branchname": "f19",
                "dist_tag": ".fc19",
                "koji_name": "f19",
                "name": "Fedora",
                "status": "Active",
                "version": "19"
              },
              "id": 8,
              "info": null,
              "package": {
                "acls": [],
                "creation_date": 1400063778.0,
                "description": "Guake is a drop-down terminal for Gnome "
                               "Desktop Environment, so you just need to "
                               "press a key to invoke him, and press again "
                               "to hide.",
                "name": "guake",
                "review_url": null,
                "status": "Approved",
                "summary": "Drop-down terminal for GNOME",
                "upstream_url": "http://guake.org/"
              },
              "status": "Awaiting Review",
              "user": "******"
            }
          ],
          "page": 1,
          "page_total": 1
        }

    .. note:: the ``date_created`` and ``date_updated`` fields are both
            timestamps expressed in
            `Unix TIME <https://en.wikipedia.org/wiki/Unix_time>`_

    """
    package = flask.request.args.get('package', None)
    packager = flask.request.args.get('packager', None)
    action = flask.request.args.get('action', None)
    status = flask.request.args.get('status', None)
    page = flask.request.args.get('page', 1)
    limit = get_limit()

    httpcode = 200
    output = {}

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(SESSION,
                                          package=package or None,
                                          packager=packager or None,
                                          action=action,
                                          status=status,
                                          limit=limit,
                                          page=page)

        cnt_actions += pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            count=True,
        )
    except pkgdblib.PkgdbException, err:  # pragma: no cover
        SESSION.rollback()
        output['output'] = 'notok'
        output['error'] = str(err)
        httpcode = 500