import json, requests
from api_auth import APICredentials, APIParams
rule_id = 'abce337d51f04b6da043cc7f28c9fe2f' # Replace with the ID for the desired rule.

class Rule:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Update a rule.
        """
        self._update_rule()

    def _update_rule(self):
        url = "{}{}{}".format(self.host, "/api/v4/rules/", rule_id)

        payload = {            
            'alternate_content_type': 'asset', # Sets the type of alternate content.
            'alternate_content_id': '062048d702734ca6a38f3e7f8e4f4488' # Replace with the desired asset ID.
        }

        headers = {'Content-Type': 'application/json'}

        response = requests.patch(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers 
        )

        print(response.json())

Rule().run()