def get_resources()

in cdk-project/lambda/python-functions/clean_endpoints.py [0:0]


def get_resources(client, next_token, before_timestamp, resource_type):
    list_req = {"MaxResults": LIST_MAX_RESULT_COUNT, "CreationTimeBefore": before_timestamp}

    if next_token:
        list_req.update({"NextToken": next_token})
    if resource_type == "MonitoringSchedules":
        response = client.list_monitoring_schedules(**list_req)
        resource_type = "MonitoringScheduleSummaries"
    elif resource_type == "ProcessingJobs":
        response = client.list_processing_jobs(**list_req)
        resource_type = "ProcessingJobSummaries"
    elif resource_type == "Endpoints":
        list_req.update({"StatusEquals": "InService"})
        response = client.list_endpoints(**list_req)
    elif resource_type == "EndpointConfigs":
        response = client.list_endpoint_configs(**list_req)
    elif resource_type == "Experiments":
        response = client.list_experiments(
            MaxResults=LIST_MAX_RESULT_COUNT, CreatedBefore=before_timestamp
        )
        resource_type = "ExperimentSummaries"
    resources = response[resource_type]
    new_next = response.get("NextToken", None)
    return resources, new_next