import json, requests, datetime, time
from api_auth import APICredentials, APIParams

class IngestPoint:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Create an ingest point.
        """
        self._create_ingest_point()

    def _create_ingest_point(self):
        url = "{}{}".format(self.host, "/api/v4/managed-slicer/slicers/ingest-points")

        payload = {
            'endpoint_name': 'My New Ingest Point', # Replace with the ingest point's name.
            'server_region_id': 'e1d9f8f3c9a24be68177654ded5b2912', # Replace with the desired region ID.
            'stream_type_name': 'RTMP' # Replace with the desired protocol name.
        }

        headers = {'Content-Type': 'application/json'}

        response = requests.post(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers 
        )

        print(response.json())

IngestPoint().run()