'added_at': {'type': 'string', 'format': 'date-time'}, 'reason': {'type': 'string'}, 'count': {'type': 'integer'}, 'retry_time': {'type': ['string', 'null'], 'format': 'date-time'} }, 'required': ['id', 'title', 'url', 'added_at', 'reason', 'count', 'retry_time'], 'additionalProperties': False } retry_entries_list_object = {'type': 'array', 'items': retry_failed_entry_object} retry_failed_entry_schema = api.schema_model('retry_failed_entry_schema', ObjectsContainer.retry_failed_entry_object) retry_entries_list_schema = api.schema_model('retry_entries_list_schema', ObjectsContainer.retry_entries_list_object) sort_choices = ('failure_time', 'id', 'title', 'url', 'reason', 'count', 'retry_time') failed_parser = api.pagination_parser(sort_choices=sort_choices) @retry_failed_api.route('/') class RetryFailed(APIResource): @etag @api.response(NotFoundError) @api.response(200, model=retry_entries_list_schema) @api.doc(parser=failed_parser) def get(self, session=None): """ List all failed entries """ args = failed_parser.parse_args() # Pagination and sorting params page = args['page'] per_page = args['per_page']
plugin_schema = api.schema_model('plugin_object', ObjectsContainer.plugin_object) plugin_list_reply_schema = api.schema_model('plugin_list_reply', ObjectsContainer.plugin_list_reply) plugin_parser = api.parser() plugin_parser.add_argument( 'include_schema', type=inputs.boolean, default=False, help='Include plugin schema. This will increase response size', ) plugins_parser = api.pagination_parser(plugin_parser) plugins_parser.add_argument('interface', case_sensitive=False, help='Show plugins which implement this interface') plugins_parser.add_argument('phase', case_sensitive=False, help='Show plugins that act on this phase') def plugin_to_dict(plugin): return { 'name': plugin.name, 'api_ver': plugin.api_ver,
def delete(self, list_id, session=None): """ Delete list by ID """ try: el.delete_list_by_id(list_id=list_id, session=session) except NoResultFound: raise NotFoundError('list_id %d does not exist' % list_id) return success_response('list successfully deleted') base_entry_schema = api.schema('base_entry_schema', ObjectsContainer.base_entry_object) entry_list_entry_base_schema = api.schema('entry_list_entry_base_schema', ObjectsContainer.entry_list_entry_base_object) entry_lists_entries_return_schema = api.schema('entry_lists_entries_return_schema', ObjectsContainer.entry_lists_entries_return_object) sort_choices = ('id', 'added', 'title', 'original_url', 'list_id') entries_parser = api.pagination_parser(sort_choices=sort_choices, default='title') @entry_list_api.route('/<int:list_id>/entries/') @api.response(NotFoundError) class EntryListEntriesAPI(APIResource): @etag @api.response(200, model=entry_lists_entries_return_schema) @api.doc(params={'list_id': 'ID of the list'}, parser=entries_parser) def get(self, list_id, session=None): """ Get entries by list ID """ try: list = el.get_list_by_id(list_id=list_id, session=session) except NoResultFound: raise NotFoundError('list_id %d does not exist' % list_id)
'additionalProperties': False, } pending_entry_schema = api.schema_model('pending.entry', ObjectsContainer.pending_entry_object) pending_entry_list_schema = api.schema_model( 'pending.entry_list', ObjectsContainer.pending_entry_list ) operation_schema = api.schema_model('pending.operation', ObjectsContainer.operation_object) filter_parser = api.parser() filter_parser.add_argument('task_name', help='Filter by task name') filter_parser.add_argument('approved', type=inputs.boolean, help='Filter by approval status') sort_choices = ('added', 'task_name', 'title', 'url', 'approved') pending_parser = api.pagination_parser(parser=filter_parser, sort_choices=sort_choices) just_task_parser = filter_parser.copy() just_task_parser.remove_argument('approved') description = 'Either \'approve\' or \'reject\'' @pending_api.route('/') class PendingEntriesAPI(APIResource): @etag @api.response(NotFoundError) @api.response(200, model=pending_entry_list_schema) @api.doc(parser=pending_parser) def get(self, session=None): """List all pending entries"""
@api.response(200, model=base_message_schema) @api.response(404) def delete(self, list_id, session=None): """ Delete list by ID """ try: movie_list = ml.get_list_by_id(list_id=list_id, session=session) except NoResultFound: raise NotFoundError('list_id %d does not exist' % list_id) session.delete(movie_list) return success_response('successfully deleted list') movie_identifiers_doc = "Use movie identifier using the following format:\n[{'ID_NAME: 'ID_VALUE'}]." sort_choices = ('id', 'added', 'title', 'year') movies_parser = api.pagination_parser(sort_choices=sort_choices, default='title') @movie_list_api.route('/<int:list_id>/movies/') class MovieListMoviesAPI(APIResource): @etag @api.response(NotFoundError) @api.response(200, model=return_movies_schema) @api.doc(params={'list_id': 'ID of the list'}, parser=movies_parser) def get(self, list_id, session=None): """ Get movies by list ID """ args = movies_parser.parse_args() # Pagination and sorting params page = args['page'] per_page = args['per_page']
release_list_schema = api.schema('release_list_schema', ObjectsContainer.release_list_schema) base_series_parser = api.parser() base_series_parser.add_argument('begin', type=inputs.boolean, default=True, help='Show series begin episode') base_series_parser.add_argument( 'latest', type=inputs.boolean, default=True, help='Show series latest downloaded episode and release') sort_choices = ('show_name', 'last_download_date') series_list_parser = api.pagination_parser(base_series_parser, sort_choices=sort_choices) series_list_parser.add_argument( 'in_config', choices=('configured', 'unconfigured', 'all'), default='configured', help="Filter list if shows are currently in configuration.") series_list_parser.add_argument('premieres', type=inputs.boolean, default=False, help="Filter by downloaded premieres only.") series_list_parser.add_argument('status', choices=('new', 'stale'), help="Filter by status") series_list_parser.add_argument('days', type=int, help="Filter status by number of days.")
@api.response(200, model=base_message_schema) @api.response(404) def delete(self, list_id, session=None): """ Delete list by ID """ try: movie_list = ml.get_list_by_id(list_id=list_id, session=session) except NoResultFound: raise NotFoundError("list_id %d does not exist" % list_id) session.delete(movie_list) return success_response("successfully deleted list") movie_identifiers_doc = "Use movie identifier using the following format:\n[{'ID_NAME: 'ID_VALUE'}]." sort_choices = ("id", "added", "title", "year") movies_parser = api.pagination_parser(sort_choices=sort_choices, default="title") @movie_list_api.route("/<int:list_id>/movies/") class MovieListMoviesAPI(APIResource): @etag @api.response(NotFoundError) @api.response(200, model=return_movies_schema) @api.doc(params={"list_id": "ID of the list"}, parser=movies_parser) def get(self, list_id, session=None): """ Get movies by list ID """ args = movies_parser.parse_args() # Pagination and sorting params page = args["page"] per_page = args["per_page"]
seen_object_schema = api.schema_model('seen_object_schema', ObjectsContainer.seen_object) seen_search_schema = api.schema_model('seen_search_schema', ObjectsContainer.seen_search_object) seen_base_parser = api.parser() seen_base_parser.add_argument( 'value', help='Filter by any field value or leave empty to get all entries') seen_base_parser.add_argument('local', type=inputs.boolean, default=None, help='Filter results by seen locality.') sort_choices = ('title', 'task', 'added', 'local', 'reason', 'id') seen_search_parser = api.pagination_parser(seen_base_parser, sort_choices) @seen_api.route('/') class SeenSearchAPI(APIResource): @etag @api.response(NotFoundError) @api.response(200, 'Successfully retrieved seen objects', seen_search_schema) @api.doc(parser=seen_search_parser, description='Get seen entries') def get(self, session): """ Search for seen entries """ args = seen_search_parser.parse_args() # Filter params value = args['value']
'interfaces': {'type': 'array', 'items': {'type': 'string'}}, 'phase_handlers': {'type': 'array', 'items': phase_object} } } plugin_list_reply = {'type': 'array', 'items': plugin_object} plugin_schema = api.schema('plugin_object', ObjectsContainer.plugin_object) plugin_list_reply_schema = api.schema('plugin_list_reply', ObjectsContainer.plugin_list_reply) plugin_parser = api.parser() plugin_parser.add_argument('include_schema', type=inputs.boolean, default=False, help='Include plugin schema. This will increase response size') plugins_parser = api.pagination_parser(plugin_parser) plugins_parser.add_argument('interface', case_sensitive=False, help='Show plugins which implement this interface') plugins_parser.add_argument('phase', case_sensitive=False, help='Show plugins that act on this phase') def plugin_to_dict(plugin): return { 'name': plugin.name, 'api_ver': plugin.api_ver, 'builtin': plugin.builtin, 'category': plugin.category, 'debug': plugin.debug, 'interfaces': plugin.interfaces, 'phase_handlers': [dict(phase=handler, priority=event.priority) for handler, event in plugin.phase_handlers.items()]
} rejected_entries_list_object = { 'type': 'array', 'items': rejected_entry_object } rejected_entry_schema = api.schema('rejected_failed_entry_schema', ObjectsContainer.rejected_entry_object) rejected_entries_list_schema = api.schema( 'rejected_entries_list_schema', ObjectsContainer.rejected_entries_list_object) sort_choices = ('added', 'id', 'title', 'url', 'expires', 'rejected_by', 'reason') rejected_parser = api.pagination_parser(sort_choices=sort_choices) @rejected_api.route('/') class Rejected(APIResource): @etag @api.response(NotFoundError) @api.response(200, model=rejected_entries_list_schema) @api.doc(parser=rejected_parser) def get(self, session=None): """ List all rejected entries """ args = rejected_parser.parse_args() # Pagination and sorting params page = args['page'] per_page = args['per_page']
seen_search_object = {'type': 'array', 'items': seen_object} seen_object_schema = api.schema_model('seen_object_schema', ObjectsContainer.seen_object) seen_search_schema = api.schema_model('seen_search_schema', ObjectsContainer.seen_search_object) seen_base_parser = api.parser() seen_base_parser.add_argument( 'value', help='Filter by any field value or leave empty to get all entries' ) seen_base_parser.add_argument( 'local', type=inputs.boolean, default=None, help='Filter results by seen locality.' ) sort_choices = ('title', 'task', 'added', 'local', 'reason', 'id') seen_search_parser = api.pagination_parser(seen_base_parser, sort_choices) @seen_api.route('/') class SeenSearchAPI(APIResource): @etag @api.response(NotFoundError) @api.response(200, 'Successfully retrieved seen objects', seen_search_schema) @api.doc(parser=seen_search_parser, description='Get seen entries') def get(self, session): """ Search for seen entries """ args = seen_search_parser.parse_args() # Filter params value = args['value'] local = args['local']
series_input_schema = api.schema_model('series_input_schema', ObjectsContainer.series_input_object) show_details_schema = api.schema_model('show_details', ObjectsContainer.single_series_object) episode_list_schema = api.schema_model('episode_list', ObjectsContainer.episode_list_schema) episode_schema = api.schema_model('episode_item', ObjectsContainer.episode_object) release_schema = api.schema_model('release_schema', ObjectsContainer.release_object) release_list_schema = api.schema_model('release_list_schema', ObjectsContainer.release_list_schema) base_series_parser = api.parser() base_series_parser.add_argument('begin', type=inputs.boolean, default=True, help='Show series begin episode') base_series_parser.add_argument('latest', type=inputs.boolean, default=True, help='Show series latest downloaded episode and release') sort_choices = ('show_name', 'last_download_date') series_list_parser = api.pagination_parser(base_series_parser, sort_choices=sort_choices) series_list_parser.add_argument('in_config', choices=('configured', 'unconfigured', 'all'), default='configured', help="Filter list if shows are currently in configuration.") series_list_parser.add_argument('premieres', type=inputs.boolean, default=False, help="Filter by downloaded premieres only.") series_list_parser.add_argument('status', choices=('new', 'stale'), help="Filter by status") series_list_parser.add_argument('days', type=int, help="Filter status by number of days.") series_list_parser.add_argument('lookup', choices=('tvdb', 'tvmaze'), action='append', help="Get lookup result for every show by sending another request to lookup API") ep_identifier_doc = "'episode_identifier' should be one of SxxExx, integer or date formatted such as 2012-12-12" @series_api.route('/') class SeriesAPI(APIResource):
}, 'required': ['details', 'filename', 'id', 'task', 'time', 'title', 'url'], 'additionalProperties': False, } history_list_object = {'type': 'array', 'items': base_history_object} history_list_schema = api.schema_model('history.list', ObjectsContainer.history_list_object) sort_choices = ('id', 'task', 'filename', 'url', 'title', 'time', 'details') # Create pagination parser history_parser = api.pagination_parser(sort_choices=sort_choices, default='time') history_parser.add_argument('task', help='Filter by task name') @history_api.route('/') @api.doc(parser=history_parser) class HistoryAPI(APIResource): @etag @api.response(NotFoundError) @api.response(200, model=history_list_schema) def get(self, session=None): """ List of previously accepted entries """ args = history_parser.parse_args() # Pagination and sorting params page = args['page']
'title': {'type': 'string'}, 'url': {'type': 'string'}, }, 'required': ['details', 'filename', 'id', 'task', 'time', 'title', 'url'], 'additionalProperties': False, } history_list_object = {'type': 'array', 'items': base_history_object} history_list_schema = api.schema_model('history.list', ObjectsContainer.history_list_object) sort_choices = ('id', 'task', 'filename', 'url', 'title', 'time', 'details') # Create pagination parser history_parser = api.pagination_parser(sort_choices=sort_choices, default='time') history_parser.add_argument('task', help='Filter by task name') @history_api.route('/') @api.doc(parser=history_parser) class HistoryAPI(APIResource): @etag @api.response(NotFoundError) @api.response(200, model=history_list_schema) def get(self, session=None): """ List of previously accepted entries """ args = history_parser.parse_args() # Pagination and sorting params page = args['page']