예제 #1
0
        or request.method == 'OPTIONS'
    ):
        return

    if not current_user.is_authenticated:
        return current_app.login_manager.unauthorized()


# API Authentication and Authorization
auth_api = api.namespace('auth', description='Authentication')

login_api_schema = api.schema_model(
    'auth.login',
    {
        'type': 'object',
        'properties': {'username': {'type': 'string'}, 'password': {'type': 'string'}},
        'required': ['username', 'password'],
        'additionalProperties': False,
    },
)

login_parser = api.parser()
login_parser.add_argument(
    'remember',
    type=inputs.boolean,
    required=False,
    default=False,
    help='Remember login (sets persistent session cookies)',
)

예제 #2
0
파일: api.py 프로젝트: yuyulklk/Flexget
                'type': 'string'
            },
            'last_execution_time': {
                'type': ['string', 'null'],
                'format': 'date-time'
            },
            'last_execution': task_status_execution_schema,
        },
        'required': ['id', 'name'],
        'additionalProperties': False,
    }

    task_status_list_schema = {'type': 'array', 'items': task_status_schema}


task_status = api.schema_model('tasks.tasks_status',
                               ObjectsContainer.task_status_schema)
task_status_list = api.schema_model('tasks.tasks_status_list',
                                    ObjectsContainer.task_status_list_schema)
task_executions = api.schema_model('tasks.tasks_executions_list',
                                   ObjectsContainer.executions_list)

sort_choices = ('last_execution_time', 'name', 'id')
tasks_parser = api.pagination_parser(sort_choices=sort_choices)
tasks_parser.add_argument(
    'include_execution',
    type=inputs.boolean,
    default=True,
    help='Include the last execution of the task',
)

예제 #3
0
    task_status_schema = {
        'type': 'object',
        'properties': {
            'id': {'type': 'integer'},
            'name': {'type': 'string'},
            'last_execution_time': {'type': ['string', 'null'], 'format': 'date-time'},
            'last_execution': task_status_execution_schema
        },
        'required': ['id', 'name'],
        'additionalProperties': False
    }

    task_status_list_schema = {'type': 'array', 'items': task_status_schema}


task_status = api.schema_model('tasks.tasks_status', ObjectsContainer.task_status_schema)
task_status_list = api.schema_model('tasks.tasks_status_list', ObjectsContainer.task_status_list_schema)
task_executions = api.schema_model('tasks.tasks_executions_list', ObjectsContainer.executions_list)

sort_choices = ('last_execution_time', 'name', 'id')
tasks_parser = api.pagination_parser(sort_choices=sort_choices)
tasks_parser.add_argument('include_execution', type=inputs.boolean, default=True,
                          help='Include the last execution of the task')


@tasks_api.route('/status/')
@status_api.route('/')
@api.doc(parser=tasks_parser)
class TasksStatusAPI(APIResource):
    @etag
    @api.response(200, model=task_status_list)