【问题标题】:AWS boto3 list codepipelinesAWS boto3 列出代码管道
【发布时间】:2018-02-17 04:03:54
【问题描述】:

我正在尝试列出 AWS 上的所有管道,并将 nextToken 作为会话令牌传递。 但是这似乎不起作用,有什么想法吗?

import boto3


def list_pipelines():
    session = boto3.Session(
        aws_access_key_id="AKIAJMO63R4OAY6HMXUQ",
        aws_secret_access_key="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"
    )
    credentials = session.get_credentials()
    print credentials
    code_pipeline = boto3.client('codepipeline')
    pipelines = code_pipeline.list_pipelines(nextToken=credentials.token)
    for i in pipelines:
        print i


def main():
    list_pipelines()

if __name__ == "__main__":
    main()

输出:

botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter nextToken, value: None, type: <type 'NoneType'>, valid types: <type 'basestring'>

【问题讨论】:

    标签: python linux amazon-web-services boto boto3


    【解决方案1】:

    您误解了nextToken 的含义。它用于分页。第一次,您在没有nextToken 参数的情况下调用。如果响应将hasMoreResults 设置为True,则在下一次调用中使用上一次调用的响应中返回的marker。

      while pipelines['hasMoreResults']:
        pipelines = code_pipeline.list_pipelines(nextToken=pipelines['marker'])
    

    List Pipelines

    请求语法

    response = client.list_pipelines(
        marker='string'
    )
    

    参数

    marker (string) -- 要返回的结果的起点。 对于第一次调用,此值应为空。只要有 更多结果,继续用marker值调用ListPipelines 从上一次调用中检索下一组结果。

    响应语法

    {
        'pipelineIdList': [
            {
                'id': 'string',
                'name': 'string'
            },
        ],
        'marker': 'string',
        'hasMoreResults': True|False
    }
    

    标记(字符串)

    下一页结果的起点。查看下一页 结果,使用此标记值再次调用 ListPipelinesOutput。如果 该值为空,没有更多结果。

    hasMoreResults(布尔值)

    表示是否有更多的结果可以通过一个 后续调用。

    【讨论】:

      猜你喜欢
      • 2021-04-07
      • 2016-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-26
      • 1970-01-01
      • 2018-11-13
      • 1970-01-01
      相关资源
      最近更新 更多