import json
import requests
from api_auth import APICredentials, APIParams
  
class Smartstart:
    def __init__(self):
        self.host = "https://services.uplynk.com"

  
    def run(self):
        self._bulk_virtual_linear_playlist()
 
    def _bulk_virtual_linear_playlist(self):
        url = "{}{}".format(self.host, "/api/v4/smart-start")
 
        description = 'Sample Playlist' # Brief description for the new playlists.
        repeat = -1 # Repeats playlists indefinitely.
        beam_break_duration = 30 # Sets 30 second ad breaks.
        assets = [
            'a404b63430a7437a99995d3285a48be1',
            '4a702cd463db4a94a90c1ea4bf9f3102',
            'da2861de60484b6eb01e8372f069ecc3'
        ] # Replace with the desired asset IDs.

        payload = {
            'desc': description,
            'repeat': repeat,
            'beam_break_duration': beam_break_duration,
            'assets': assets
        }
 
        headers = {'Content-Type': 'application/json'}
 
        response = requests.post(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers
        )
 
        print(response.json())
  
Smartstart().run()