Skip to content
Snippets Groups Projects
internal_controller.py 3.14 KiB
Newer Older
  • Learn to ignore specific revisions
  • David Trattnig's avatar
    David Trattnig committed
    import connexion
    import six
    
    
    David Trattnig's avatar
    David Trattnig committed
    from src.rest.models.clock_info import ClockInfo  # noqa: E501
    
    from src.rest.models.health_info import HealthInfo  # noqa: E501
    
    David Trattnig's avatar
    David Trattnig committed
    from src.rest.models.inline_response400 import InlineResponse400  # noqa: E501
    
    from src.rest.models.play_log_entry import PlayLogEntry  # noqa: E501
    from src.rest.models.status_entry import StatusEntry  # noqa: E501
    from src.rest import util
    
    David Trattnig's avatar
    David Trattnig committed
    
    
    from flask import current_app
    
    from dateutil.parser import parse
    
    David Trattnig's avatar
    David Trattnig committed
    def activate_engine(engine_number):  # noqa: E501
        """Set active engine
    
    David Trattnig's avatar
    David Trattnig committed
    
    
    David Trattnig's avatar
    David Trattnig committed
        Activates one engine and deactivates the other  # noqa: E501
    
    David Trattnig's avatar
    David Trattnig committed
    
    
    David Trattnig's avatar
    David Trattnig committed
        :param engine_number: Number of the engine
        :type engine_number: int
    
    David Trattnig's avatar
    David Trattnig committed
    
    
    David Trattnig's avatar
    David Trattnig committed
        :rtype: None
    
    David Trattnig's avatar
    David Trattnig committed
        """
    
    David Trattnig's avatar
    David Trattnig committed
        return 'do some magic!'
    
    David Trattnig's avatar
    David Trattnig committed
    def add_playlog(body):  # noqa: E501
    
    David Trattnig's avatar
    David Trattnig committed
        """Adds an entry to the playlog
    
        Stores the passed playlog entry  # noqa: E501
    
    
    David Trattnig's avatar
    David Trattnig committed
        :param body: 
        :type body: dict | bytes
    
    David Trattnig's avatar
    David Trattnig committed
        :rtype: None
    
    David Trattnig's avatar
    David Trattnig committed
        """
    
    David Trattnig's avatar
    David Trattnig committed
        if connexion.request.is_json:
            body = PlayLogEntry.from_dict(connexion.request.get_json())  # noqa: E501
    
    David Trattnig's avatar
    David Trattnig committed
        service = current_app.config['SERVICE']
    
    David Trattnig's avatar
    David Trattnig committed
        service.store_playlog(body)
    
    David Trattnig's avatar
    David Trattnig committed
    
    
    David Trattnig's avatar
    David Trattnig committed
    def clock_info():  # noqa: E501
        """Get all information to display the studio clock
    
    David Trattnig's avatar
    David Trattnig committed
        Retrieves the currently playing schedule, its playlist and entries plus the next schedule for being used by the studio clock.  # noqa: E501
    
    David Trattnig's avatar
    David Trattnig committed
        :rtype: ClockInfo
    
        """
        return 'do some magic!'
    
    
    
    David Trattnig's avatar
    David Trattnig committed
    def get_active_engine():  # noqa: E501
        """Get active engine
    
        Retrieves the status entry of the currently active engine  # noqa: E501
    
    
        :rtype: StatusEntry
        """
        return 'do some magic!'
    
    
    
    def get_engine_health(engine_number):  # noqa: E501
        """Get most recent health info
    
        Retrieves the most recent health info of the requested engine  # noqa: E501
    
        :param engine_number: Number of the engine
        :type engine_number: int
    
        :rtype: HealthInfo
        """
        return 'do some magic!'
    
    
    
    David Trattnig's avatar
    David Trattnig committed
    def get_report(year_month):  # noqa: E501
        """Report for one month
    
        Returns a report for the given month  # noqa: E501
    
        :param year_month: Month to create the report for in the format \"yyyy_mm\"
        :type year_month: str
    
        :rtype: List[PlayLogEntry]
        """
        return 'do some magic!'
    
    
    
    David Trattnig's avatar
    David Trattnig committed
    def list_playlog(date_time, page=None, limit=None):  # noqa: E501
        """List tracks in the play-log since the given timestamp
    
        Get paginated playlog entries for since the given timestamp.  # noqa: E501
    
        :param date_time: Get entries after this timestamp (e.g. '2020-08-29T09:12:33.001Z')
    
    David Trattnig's avatar
    David Trattnig committed
        :type date_time: str
    
    David Trattnig's avatar
    David Trattnig committed
        :param page: The number of items to skip before starting to collect the result set
        :type page: int
        :param limit: The numbers of items to return per page
        :type limit: int
    
        :rtype: List[PlayLogEntry]
        """
        service = current_app.config['SERVICE']
    
        date_time = parse(date_time)
        return service.list_playlog(page, limit, date_time)
    
    def log_engine_health(engine_number):  # noqa: E501
        """Log health info
    
        Logs another health entry for the given engine  # noqa: E501
    
        :param engine_number: Number of the engine
        :type engine_number: int
    
        :rtype: None
        """
        return 'do some magic!'