# CommandsResource Resource

### GET /commands/commands

Retrieve detailed information on all recent commands.

Request Parameters
name | type | description | default
--- | --- | --- | ---
endTime | query | timestamp of the command end time | -1
limit | query | command count to return (from offset) | 50
name | query | the command name, unique for the command class HdfsCreateSnapshotCommand#COMMAND_NAME | n/a
offset | query | command position to start | 0
startTime | query | timestamp of the command start time | -1
success | query | whether the command was successful, if already finished | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiCommandList (JSON) | Detailed information about recent asynchronous commands.

### GET /commands/{commandId}

Retrieve detailed information on an asynchronous command.

Cloudera Manager keeps the results and statuses of asynchronous commands, which have non-negative command IDs. On the other hand, synchronous commands complete immediately, and their results are passed back in the return object of the command execution API call. Outside of that return object, there is no way to check the result of a synchronous command.

Request Parameters
name | type | description | default
--- | --- | --- | ---
commandId | path | The command id. | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiCommand (JSON) | Detailed command information.

### GET /commands/commandByCorrelationId/{correlationId}

Retrieve command by the correlation ID that was provided at command creation. Used to recover command references when the command ID is not available.

Request Parameters
name | type | description | default
--- | --- | --- | ---
correlationId | path | Correlation ID provided at command creation | n/a
startTime | query | Timestamp from which the command was started | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiCommand (JSON) | Detailed information about the matching command

### POST /commands/{commandId}/abort

Abort a running command.

Request Parameters
name | type | description | default
--- | --- | --- | ---
commandId | path | The command id. | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiCommand (JSON) | Detailed command information.

### GET /commands/{commandId}/download

Download the end result of a command. Content-Type header is explicitly set in the implementation instead of using annotation. In case the MIME type is not set for the command result, application/octet-stream is set.

Request Parameters
name | type | description | default
--- | --- | --- | ---
commandId | path | The command id. | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | object (JSON) | The command result.

### GET /commands/{commandId}/replicationReport

Get the replication report CSV files.

Request Parameters
name | type | description | default
--- | --- | --- | ---
commandId | path | The command id. | n/a
type | query | The requested report type. | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | object (JSON) | response The response, with the report as a CSV attachment.

### POST /commands/{commandId}/retry

Try to rerun a command.

Request Parameters
name | type | description | default
--- | --- | --- | ---
commandId | path | ID of the command that needs to be run. | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiCommand (JSON) | Command that represents the retry attempt.

### GET /commands/{commandId}/steps

Retrieve detailed information of an asynchronous command including the command steps.

Cloudera Manager keeps the results and statuses of asynchronous commands, which have non-negative command IDs. On the other hand, synchronous commands complete immediately, and their results are passed back in the return object of the command execution API call. Outside of that return object, there is no way to check the result of a synchronous command.

Request Parameters
name | type | description | default
--- | --- | --- | ---
commandId | path | The command id. | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiCommandWithSteps (JSON) | Detailed command information including the command steps.

### GET /commands/{commandId}/logs/stderr

Download a zip-compressed archive of standard error outputs for the command's one-off processes. Log files are returned zipped together.

Request Parameters
name | type | description | default
--- | --- | --- | ---
commandId | path | The command id. | n/a

Response Body
media type | data type | description
--- | --- | ---
application/octet-stream | object | Contents of the role's standard output.

### GET /commands/{commandId}/logs/stdout

Download a zip-compressed archive of standard outputs for the command's one-off processes. Log files are returned zipped together.

Request Parameters
name | type | description | default
--- | --- | --- | ---
commandId | path | The command id. | n/a

Response Body
media type | data type | description
--- | --- | ---
application/octet-stream | object | Contents of the role's standard output.