import requests
from api_auth import APICredentials, APIParams
 
class KeyRotationSchedule:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Define a rotation schedule for your static encryption key.
        """
        self._update_krs()

    def _update_krs(self):
 
        krs_data = dict()
        url = "{}{}".format(self.host, "/api/v3/drm/key-rotation-schedule/create-or-update")

        new_krs_data = {
            'next_rotation': 1576470581706,
            'enabled': True,
            'frequency': 1,
            'unit': 'd',
            'hour': 20
        }

        krs_data['item'] = new_krs_data

        response = requests.post(
            url, data=APIParams(APICredentials()).get_params(krs_data)
        )

        print(response.json())

KeyRotationSchedule().run()