如何管理具有超过500个结果的GCP/Google API客户端调用
在下面采样python代码。正如预期的那样,由于' MaxResults'> MaxResults 0和500,我收到不超过500个项目:
from googleapiclient import discovery
resource_object = discovery.build('compute', 'v1')
result = resource_object.firewalls().list(project="myproject-123456").execute()
print(len(result.get('items', [])))
500
但是我知道有500多个项目。
在AWS/BOTO3中,通过。 GCP有等效吗?
Sample Python code below. As expected, since 'maxResults' must be between 0 and 500, I get no more than 500 items back:
from googleapiclient import discovery
resource_object = discovery.build('compute', 'v1')
result = resource_object.firewalls().list(project="myproject-123456").execute()
print(len(result.get('items', [])))
500
But I know there are more than 500 items.
In AWS / boto3, this problem is solved via Paginators. Is there an equivalent in GCP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到这样做的方法是使用 pagetoken 。找不到任何python示例,所以这里是:
Found the way to do this is using pageToken. Couldn't find any Python examples so here goes: