2016-11-21 20:28:11 +01:00
|
|
|
"""
|
2016-12-14 18:29:04 +01:00
|
|
|
.. module: lemur.logs.views
|
2016-11-21 20:28:11 +01:00
|
|
|
:platform: Unix
|
2018-05-29 19:18:16 +02:00
|
|
|
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
|
2016-11-21 20:28:11 +01:00
|
|
|
:license: Apache, see LICENSE for more details.
|
|
|
|
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
|
|
|
"""
|
|
|
|
from flask import Blueprint
|
2016-11-23 06:11:20 +01:00
|
|
|
from flask_restful import reqparse, Api
|
2016-11-21 20:28:11 +01:00
|
|
|
|
|
|
|
from lemur.common.schema import validate_schema
|
|
|
|
from lemur.common.utils import paginated_parser
|
|
|
|
|
|
|
|
from lemur.auth.service import AuthenticatedResource
|
|
|
|
from lemur.logs.schemas import logs_output_schema
|
|
|
|
|
|
|
|
from lemur.logs import service
|
|
|
|
|
|
|
|
|
|
|
|
mod = Blueprint('logs', __name__)
|
|
|
|
api = Api(mod)
|
|
|
|
|
|
|
|
|
|
|
|
class LogsList(AuthenticatedResource):
|
|
|
|
""" Defines the 'logs' endpoint """
|
|
|
|
def __init__(self):
|
|
|
|
self.reqparse = reqparse.RequestParser()
|
|
|
|
super(LogsList, self).__init__()
|
|
|
|
|
|
|
|
@validate_schema(None, logs_output_schema)
|
|
|
|
def get(self):
|
|
|
|
"""
|
|
|
|
.. http:get:: /logs
|
|
|
|
|
|
|
|
The current log list
|
|
|
|
|
|
|
|
**Example request**:
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
|
|
GET /logs HTTP/1.1
|
|
|
|
Host: example.com
|
|
|
|
Accept: application/json, text/javascript
|
|
|
|
|
|
|
|
**Example response**:
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
|
|
HTTP/1.1 200 OK
|
|
|
|
Vary: Accept
|
|
|
|
Content-Type: text/javascript
|
|
|
|
|
|
|
|
{
|
|
|
|
"items": [
|
|
|
|
]
|
|
|
|
"total": 2
|
|
|
|
}
|
|
|
|
|
|
|
|
:query sortBy: field to sort on
|
2016-12-14 18:29:04 +01:00
|
|
|
:query sortDir: asc or desc
|
2016-11-21 20:28:11 +01:00
|
|
|
:query page: int default is 1
|
|
|
|
:query filter: key value pair format is k;v
|
|
|
|
:query count: count number default is 10
|
|
|
|
:reqheader Authorization: OAuth token to authenticate
|
|
|
|
:statuscode 200: no error
|
|
|
|
"""
|
|
|
|
parser = paginated_parser.copy()
|
|
|
|
parser.add_argument('owner', type=str, location='args')
|
|
|
|
parser.add_argument('id', type=str, location='args')
|
|
|
|
args = parser.parse_args()
|
|
|
|
return service.render(args)
|
|
|
|
|
|
|
|
|
|
|
|
api.add_resource(LogsList, '/logs', endpoint='logs')
|