import json, requests, datetime, time
from api_auth import APICredentials, APIParams

class LiveChannel:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Create a live channel.
        """
        self._create_live_channel()

    def _create_live_channel(self):
        url = "{}{}".format(self.host, "/api/v4/channels")

        payload = {
            'desc': 'My New Live Channel', # Replace with the live channel's name.
            'slicer_id': 'mySlicer1', # Replace with the desired Live Slicer ID.
            'use_chsched': 2 # Enables scheduling.
        }

        headers = {'Content-Type': 'application/json'}

        response = requests.post(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers 
        )

        print(response.json())

LiveChannel().run()