ListSteps 搭配 AWS SDK 或 CLI 使用 - AWS SDK 程式碼範例

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

ListSteps 搭配 AWS SDK 或 CLI 使用

下列程式碼範例示範如何使用 ListSteps

CLI
AWS CLI

下列命令會列出叢集中叢集 ID 為 j-3SD91U2E1L2QX 的所有步驟:

aws emr list-steps --cluster-id j-3SD91U2E1L2QX
  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListSteps

Python
適用於 Python 的 SDK (Boto3)
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

def list_steps(cluster_id, emr_client): """ Gets a list of steps for the specified cluster. In this example, all steps are returned, including completed and failed steps. :param cluster_id: The ID of the cluster. :param emr_client: The Boto3 EMR client object. :return: The list of steps for the specified cluster. """ try: response = emr_client.list_steps(ClusterId=cluster_id) steps = response["Steps"] logger.info("Got %s steps for cluster %s.", len(steps), cluster_id) except ClientError: logger.exception("Couldn't get steps for cluster %s.", cluster_id) raise else: return steps
  • 如需 API 詳細資訊,請參閱《AWS SDK for Python (Boto3) API 參考》中的 ListSteps

SAP ABAP
適用於 SAP ABAP 的開發套件
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

TRY. oo_result = lo_emr->liststeps( iv_clusterid = iv_cluster_id ). DATA(lt_steps) = oo_result->get_steps( ). DATA(lv_step_count) = lines( lt_steps ). MESSAGE |Retrieved { lv_step_count } steps for cluster| TYPE 'I'. CATCH /aws1/cx_emrinternalserverex INTO DATA(lo_internal_error). DATA(lv_error) = lo_internal_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. CATCH /aws1/cx_emrinvalidrequestex INTO DATA(lo_invalid_error). lv_error = lo_invalid_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. ENDTRY.
  • 如需 API 詳細資訊,請參閱《適用於 AWS SAP ABAP 的 SDK API 參考》中的 ListSteps