Skip to content

list_commands

list_commands(
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    command_id: Optional[CommandId] = None,
    instance_id: Optional[InstanceId] = None,
    max_results: Optional[CommandMaxResults] = None,
    next_token: Optional[NextToken] = None,
    filters: Optional[CommandFilterList] = None,
) -> ListCommandsResult

Lists the commands requested by users of the Amazon Web Services account.

Parameters:

  • command_id (Optional[CommandId], default: None ) –

    (Optional) If provided, lists only the specified command.

  • instance_id (Optional[InstanceId], default: None ) –

    (Optional) Lists commands issued against this managed node ID.

    You can't specify a managed node ID in the same command that you specify Status = Pending. This is because the command hasn't reached the managed node yet.

  • max_results (Optional[CommandMaxResults], default: None ) –

    (Optional) The maximum number of items to return for this call. The call also returns a token that you can specify in a subsequent call to get the next set of results.

  • next_token (Optional[NextToken], default: None ) –

    (Optional) The token for the next set of items to return. (You received this token from a previous call.)

  • filters (Optional[CommandFilterList], default: None ) –

    (Optional) One or more filters. Use a filter to return a more specific list of results.

Raises:

  • InternalServerError –

    An error occurred on the server side.

  • InvalidCommandId –

    The specified command ID isn't valid. Verify the ID and try again.

  • InvalidFilterKey –

    The specified key isn't valid.

  • InvalidInstanceId –

    The following problems can cause this exception:

    • You don't have permission to access the managed node.

    • Amazon Web Services Systems Manager Agent (SSM Agent) isn't running. Verify that SSM Agent is running.

    • SSM Agent isn't registered with the SSM endpoint. Try reinstalling SSM Agent.

    • The managed node isn't in a valid state. Valid states are: Running, Pending, Stopped, and Stopping. Invalid states are: Shutting-down and Terminated.

  • InvalidNextToken –

    The specified token isn't valid.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_ssm/_services/ssm.py
def list_commands(
    self,
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    command_id: Optional["capo_ssm.types.command_id.CommandId"] = None,
    instance_id: Optional["capo_ssm.types.instance_id.InstanceId"] = None,
    max_results: Optional[
        "capo_ssm.types.command_max_results.CommandMaxResults"
    ] = None,
    next_token: Optional["capo_ssm.types.next_token.NextToken"] = None,
    filters: Optional[
        "capo_ssm.types.command_filter_list.CommandFilterList"
    ] = None,
) -> "capo_ssm.types.list_commands_result.ListCommandsResult":
    """<p>Lists the commands requested by users of the Amazon Web Services account.</p>

    Args:
        command_id: <p>(Optional) If provided, lists only the specified command.</p>
        instance_id: <p>(Optional) Lists commands issued against this managed node ID.</p> <note> <p>You can't specify a managed node ID in the same command that you specify <code>Status</code> = <code>Pending</code>. This is because the command hasn't reached the managed node yet.</p> </note>
        max_results: <p>(Optional) The maximum number of items to return for this call. The call also returns a token that you can specify in a subsequent call to get the next set of results.</p>
        next_token: <p>(Optional) The token for the next set of items to return. (You received this token from a previous call.)</p>
        filters: <p>(Optional) One or more filters. Use a filter to return a more specific list of results. </p>

    Raises:
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.invalid_command_id.InvalidCommandId: <p>The specified command ID isn't valid. Verify the ID and try again.</p>
        capo_ssm.errors.invalid_filter_key.InvalidFilterKey: <p>The specified key isn't valid.</p>
        capo_ssm.errors.invalid_instance_id.InvalidInstanceId: <p>The following problems can cause this exception:</p> <ul> <li> <p>You don't have permission to access the managed node.</p> </li> <li> <p>Amazon Web Services Systems Manager Agent (SSM Agent) isn't running. Verify that SSM Agent is running.</p> </li> <li> <p>SSM Agent isn't registered with the SSM endpoint. Try reinstalling SSM Agent.</p> </li> <li> <p>The managed node isn't in a valid state. Valid states are: <code>Running</code>, <code>Pending</code>, <code>Stopped</code>, and <code>Stopping</code>. Invalid states are: <code>Shutting-down</code> and <code>Terminated</code>.</p> </li> </ul>
        capo_ssm.errors.invalid_next_token.InvalidNextToken: <p>The specified token isn't valid.</p>
        capo_ssm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ssm.types.list_commands_request.ListCommandsRequest]",
    ) -> OperationResponse[
        "capo_ssm.types.list_commands_result.ListCommandsResult"
    ]:
        import capo_ssm._operations.amazon_ssm.list_commands

        output, http_response = (
            capo_ssm._operations.amazon_ssm.list_commands.list_commands(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_ssm.types.list_commands_result.ListCommandsResult",
    ) -> dict[str, Any]:
        import capo_ssm.types.list_commands_result

        return capo_ssm.types.list_commands_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ListCommands", redact_output=_redact_output),
    )
    input_: capo_ssm.types.list_commands_request.ListCommandsRequest = {}
    if command_id is not None:
        input_["command_id"] = command_id
    if instance_id is not None:
        input_["instance_id"] = instance_id
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if filters is not None:
        input_["filters"] = filters

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output