Boto3 Inspector v2 list_findings' nextToken 初始值是多少?
What is Boto3 Inspector v2 list_findings' nextToken initial value?
我正在使用 boto3 Python 列出 Inspector v2 的发现,在循环中使用 list_findings() 方法,根据 AWS Boto3 Inspector2 Docs 我必须设置此值对于列表操作的第一个请求,参数为 null 但在变量 next_token:
的所有这些情况下不断出现错误
nextToken = None: botocore.exceptions.ParamValidationError: 参数验证失败:
参数 nextToken 的类型无效,值:None,类型:,有效类型:
nextToken = 'null': botocore.errorfactory.ValidationException:调用ListFindings操作时发生错误(ValidationException):Pagination token exception in操作 'ListFindings': 无效的负载包装模式 -24855
nextToken = 空字符串:调用ListFindings操作时发生错误(ValidationException):操作中出现分页令牌异常'ListFindings':有效载荷无效(无加密模式版本)
这是我的代码:
import boto3
inspector = boto3.client("inspector2")
next_token = "" # I change the value of this variable
while True:
response = inspector.list_findings(
filterCriteria={
'findingStatus': [
{
'comparison': 'EQUALS',
'value': 'ACTIVE'
},
],
'findingType': [
{
'comparison': 'EQUALS',
'value': 'PACKAGE_VULNERABILITY'
},
],
},
nextToken=next_token
)
next_token= response.get("nextToken")
# Some Code Here
if next_token == None:
break
我对第一个请求的 nextToken 值应该是多少感到困惑?
使用起来会更方便paginate as explained in AWS docs:
# Create a client
inspector = boto3.client("inspector2")
# Create a reusable Paginator
paginator = inspector.get_paginator('list_findings')
# Create a PageIterator from the Paginator
page_iterator = paginator.paginate(filterCriteria={
'findingStatus': [
{
'comparison': 'EQUALS',
'value': 'ACTIVE'
},
],
'findingType': [
{
'comparison': 'EQUALS',
'value': 'PACKAGE_VULNERABILITY'
},
],
})
for page in page_iterator:
print(page)
我正在使用 boto3 Python 列出 Inspector v2 的发现,在循环中使用 list_findings() 方法,根据 AWS Boto3 Inspector2 Docs 我必须设置此值对于列表操作的第一个请求,参数为 null 但在变量 next_token:
的所有这些情况下不断出现错误nextToken = None: botocore.exceptions.ParamValidationError: 参数验证失败: 参数 nextToken 的类型无效,值:None,类型:
,有效类型: nextToken = 'null': botocore.errorfactory.ValidationException:调用ListFindings操作时发生错误(ValidationException):Pagination token exception in操作 'ListFindings': 无效的负载包装模式 -24855
nextToken = 空字符串:调用ListFindings操作时发生错误(ValidationException):操作中出现分页令牌异常'ListFindings':有效载荷无效(无加密模式版本)
这是我的代码:
import boto3
inspector = boto3.client("inspector2")
next_token = "" # I change the value of this variable
while True:
response = inspector.list_findings(
filterCriteria={
'findingStatus': [
{
'comparison': 'EQUALS',
'value': 'ACTIVE'
},
],
'findingType': [
{
'comparison': 'EQUALS',
'value': 'PACKAGE_VULNERABILITY'
},
],
},
nextToken=next_token
)
next_token= response.get("nextToken")
# Some Code Here
if next_token == None:
break
我对第一个请求的 nextToken 值应该是多少感到困惑?
使用起来会更方便paginate as explained in AWS docs:
# Create a client
inspector = boto3.client("inspector2")
# Create a reusable Paginator
paginator = inspector.get_paginator('list_findings')
# Create a PageIterator from the Paginator
page_iterator = paginator.paginate(filterCriteria={
'findingStatus': [
{
'comparison': 'EQUALS',
'value': 'ACTIVE'
},
],
'findingType': [
{
'comparison': 'EQUALS',
'value': 'PACKAGE_VULNERABILITY'
},
],
})
for page in page_iterator:
print(page)