import json, requests
from api_auth import APICredentials, APIParams
channel_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired live channel.
blackout_id = 'degf8923f093kfd932kd9fa4' # Replace with the ID for the desired blackout configuration.

class Blackout:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Update a blackout configuration.
        """
        self._update_blackout()

    def _update_blackout(self):
        url = "{}{}{}{}{}".format(self.host, "/api/v4/channels/", channel_id, "/blackouts", blackout_id)

        payload = {            
            'blackout_id': 'NorthAmerica', # Replace with the desired blackout ID.
        }

        headers = {'Content-Type': 'application/json'}

        response = requests.patch(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers 
        )

        print(response.json())

Blackout().run()