dazza-codes / aio-aws

Asyncio utils for AWS Services
Apache License 2.0
3 stars 1 forks source link

jobs-db API to support similar options to awscli for list-jobs #57

Open dazza-codes opened 3 years ago

dazza-codes commented 3 years ago

See options for https://awscli.amazonaws.com/v2/documentation/api/latest/reference/batch/list-jobs.html


import boto3
client = boto3.client('batch')
queue = 'project-queue-prod'

query_runnable = client.list_jobs(jobQueue=queue, jobStatus='RUNNABLE')
next_token = query_runnable.get('nextToken')
job_list = query_runnable['jobSummaryList']

while next_token:
    query_runnable = client.list_jobs(jobQueue=queue, jobStatus='RUNNABLE', nextToken=next_token)
    next_token = query_runnable.get('nextToken')
    job_list.extend(query_runnable['jobSummaryList'])

job_names = [r['jobName'] for r in job_list]