BackupDeviceActionResult


class BackupDeviceActionResult


Results returned from a BackupDeviceAction back to the host orchestrator.

BackupActionOutputKeys documents every key the actions bundled with this library produce. Actions built with success and failure always report BackupActionOutputKeys.STATUS, and report BackupActionOutputKeys.ERROR only alongside a failure. Additional keys may be returned to carry data back to the host, which forwards the whole payload to the caller.

Summary

Public companion functions

BackupDeviceActionResult
failure(errorMessage: String, payload: Map<String, String>)

Returns a result reporting BackupActionValues.STATUS_FAILURE together with errorMessage.

BackupDeviceActionResult
success(payload: Map<String, String>)

Returns a result reporting BackupActionValues.STATUS_SUCCESS.

Public constructors

Public functions

open operator Boolean
equals(other: Any?)
operator String?
get(key: String)

Returns the result stored under key, or null when the action did not produce it.

open Int
open String

Public properties

String?

The reported BackupActionOutputKeys.ERROR, or null when the action did not fail.

Boolean

Whether the action completed its work.

Map<String, String>

key-value results produced by the action, keyed by BackupActionOutputKeys

String?

The reported BackupActionOutputKeys.STATUS, or null for an action that does not report one.

Public companion functions

failure

Added in 1.0.0-alpha02
fun failure(errorMessage: String, payload: Map<String, String> = emptyMap()): BackupDeviceActionResult

Returns a result reporting BackupActionValues.STATUS_FAILURE together with errorMessage.

Parameters
errorMessage: String

human-readable description of the failure, surfaced to the host as BackupActionOutputKeys.ERROR

payload: Map<String, String> = emptyMap()

additional data to return to the host; BackupActionOutputKeys.STATUS and BackupActionOutputKeys.ERROR entries it contains are overwritten

success

Added in 1.0.0-alpha02
fun success(payload: Map<String, String> = emptyMap()): BackupDeviceActionResult

Returns a result reporting BackupActionValues.STATUS_SUCCESS.

Parameters
payload: Map<String, String> = emptyMap()

additional data to return to the host; a BackupActionOutputKeys.STATUS entry it contains is overwritten

Public constructors

BackupDeviceActionResult

Added in 1.0.0-alpha02
BackupDeviceActionResult(payload: Map<String, String> = emptyMap())

Public functions

equals

open operator fun equals(other: Any?): Boolean

get

Added in 1.0.0-alpha02
operator fun get(key: String): String?

Returns the result stored under key, or null when the action did not produce it.

Any key may be read, so a custom BackupDeviceAction can return keys of its own alongside the BackupActionOutputKeys constants.

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

errorMessage

Added in 1.0.0-alpha02
val errorMessage: String?

The reported BackupActionOutputKeys.ERROR, or null when the action did not fail.

Reported only for a result that isSuccess rejects. A successful action may legitimately carry a BackupActionOutputKeys.ERROR entry of its own — an empty string, or a diagnostic unrelated to the outcome — and surfacing that as a failure message would be misleading. This mirrors the host, which reads the key under exactly the same conditions.

See also
isSuccess

isSuccess

Added in 1.0.0-alpha02
val isSuccess: Boolean

Whether the action completed its work.

Resolved in two steps:

  • A reported BackupActionOutputKeys.STATUS decides on its own. Only BackupActionValues.STATUS_FAILURE, compared without regard to case, means failure; status is a generic key that custom actions also use to publish their own vocabulary, so an unrecognized value is reported as successful rather than being guessed at.

  • With no status at all, a non-empty BackupActionOutputKeys.ERROR means failure. An action that reports only an error would otherwise be read as passing.

Use BackupDeviceActionResult.failure to report a failure that callers and the host will honor.

payload

Added in 1.0.0-alpha02
val payload: Map<String, String>

key-value results produced by the action, keyed by BackupActionOutputKeys

status

Added in 1.0.0-alpha02
val status: String?

The reported BackupActionOutputKeys.STATUS, or null for an action that does not report one.