將 ListFlowVersions 與 AWS SDK 搭配使用
以下程式碼範例顯示如何使用 ListFlowVersions。
- Python
-
- 適用於 Python (Boto3) 的 SDK
-
注意
GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 列出 Amazon Bedrock 流程的版本。
def list_flow_versions(client, flow_id): """ Lists the versions of an Amazon Bedrock flow. Args: client: Amazon bedrock agent boto3 client. flow_id (str): The identifier of the flow. Returns: dict: The response from ListFlowVersions. """ try: finished = False logger.info("Listing flow versions for flow: %s.", flow_id) response = client.list_flow_versions( flowIdentifier=flow_id, maxResults=10) while finished is False: print(f"Versions for flow:{flow_id}") for version in response['flowVersionSummaries']: print(f"Version: {version['version']}") print(f"Status: {version['status']}\n") if 'nextToken' in response: next_token = response['nextToken'] response = client.list_flow_versions(maxResults=10, nextToken=next_token) else: finished = True logging.info("Successfully listed flow versions for flow %s.", flow_id) return response except ClientError as e: logging.exception("Client error listing flow versions: %s", str(e)) raise except Exception as e: logging.exception("Unexpected error listing flow versions: %s", str(e)) raise-
如需 API 詳細資訊,請參閱《AWS SDK for Python (Boto3) API 參考》中的 ListFlowVersions。
-
如需完整的 AWS SDK 開發人員指南和程式碼範例清單,請參閱 使用 Amazon Bedrock 搭配 AWS SDK。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。
ListFlowAliases
ListFlows