2021年1月23日星期六

How do i fix the NextPageToken not working in AWS code?

I have a script that is trying to get a lot of data and the part of the code that uses next page token isn't working, how do i fix this?

results = []    token = None  while True:      if token:          kwargs = {'NextPageToken': token}      else:          kwargs = {}      data = cd.get_cost_and_usage(TimePeriod={'Start': '2020-03-11', 'End':    '2020-06-10'}, Granularity='DAILY', Metrics=['AmortizedCost'],                                  GroupBy=[{'Type': 'DIMENSION', 'Key':   'LINKED_ACCOUNT'}]} ,{'Dimensions': {'Key': 'LINKED_ACCOUNT','Values':   ['123948500267568']}}]}, **kwargs)      for info in data['ResultsByTime']:         for group in info['Groups']:              print(group['Keys'][0], info['TimePeriod']['Start'],   group['Metrics']['AmortizedCost']['Amount'])#, group['Keys'][1])      token = data.get('NextPageToken')      if not token:          break  
https://stackoverflow.com/questions/65867018/how-do-i-fix-the-nextpagetoken-not-working-in-aws-code January 24, 2021 at 12:03PM

没有评论:

发表评论