def get_templates()

in clone_mediaconvert_resources/clone_mediaconvert_resources.py [0:0]


def get_templates(source_client, file, region):

    try:
        response = source_client.list_job_templates(ListBy='NAME')
        results = response['JobTemplates']
        while "NextToken" in response:
            response = source_client.list_job_templates(NextToken=response["NextToken"])
            results.extend(response["JobTemplates"])

        if len(results) == 0:
            return
        else:
            path = clean_templates(results, file, region)
            return path
    except botocore.exceptions.ClientError as error:
        if error.response['Error']['Code'] == 'AccessDeniedException':
            print("No permissions to access the MediaConvert API and get job templates,"
                  " please check the AWS CLI credentials")
            exit(-1)
    except:
        print("Error processing job template resources in source region")
        exit(-1)