def enable_cloud_ddns(api):
"""
Enable Cloud DDNS on the router.
:param api: The RouterOS API object.
"""
# Enable Cloud DDNS
print("Enabling Cloud DDNS")
try:
api.get_resource('/ip/cloud').set(ddns_enabled='yes')
except routeros_api.exceptions.RouterOsApiCommunicationError as e:
raise e
# Wait for the Cloud DDNS address to be assigned
time.sleep(3)
# Get the Cloud DDNS address
cloud_ddns_address = api.get_resource('/ip/cloud').get()[0]['dns-name']
print(f"Cloud DDNS address: {cloud_ddns_address}")
# Get the Cloud DDNS status#
cloud_ddns_status = api.get_resource('/ip/cloud').get()[0]['status']
print(f"Cloud DDNS status: {cloud_ddns_status}")