import json, requests
from api_auth import APICredentials, APIParams
audience_id = 'Hak3zjnPLSW5o0j8GMpzRMsa' # Replace with the ID for the desired audience.

class Audience:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Update an audience.
        """
        self._update_audience()

    def _update_audience(self):
        url = "{}{}{}".format(self.host, "/api/v4/audiences/", audience_id)

        payload = {            
            'country_codes': ['US', 'MX'] # Replace with the desired country codes.
        }

        headers = {'Content-Type': 'application/json'}

        response = requests.patch(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers 
        )

        print(response.json())

Audience().run()