reference

Class: WorkContext

task/work.WorkContext

Work Context

Description

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new WorkContext(activity, options?)

Parameters

NameType
activityActivity
options?WorkOptions

Defined in

src/task/work.ts:61

Properties

provider

Optional Readonly provider: Object

Type declaration

NameType
namestring
idstring
networkConfig?object

Defined in

src/task/work.ts:52


agreementId

Readonly agreementId: string

Defined in

src/task/work.ts:53


activityId

Readonly activityId: string

Defined in

src/task/work.ts:54

Methods

before

before(): Promise<void | Result<any>[]>

Returns

Promise<void | Result<any>[]>

Defined in

src/task/work.ts:74


run

run(commandLine, options?): Promise<Result<any>>

Execute a command on provider using a shell (/bin/sh).

Parameters

NameTypeDescription
commandLinestringShell command to execute.
options?CommandOptionsAdditional run options.

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:117

run(executable, args, options?): Promise<Result<any>>

Execute an executable on provider.

Parameters

NameTypeDescription
executablestringExecutable to run.
argsstring[]Executable arguments.
options?CommandOptionsAdditional run options.

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:126


transfer

transfer(from, to, options?): Promise<Result<any>>

Generic transfer command, requires the user to provide a publicly readable transfer source

Parameters

NameTypeDescription
fromstringpublicly available resource for reading. Supported protocols: file, http, ftp or gftp
tostringfile path
options?CommandOptionsAdditional run options.

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:145


uploadFile

uploadFile(src, dst, options?): Promise<Result<any>>

Parameters

NameType
srcstring
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:149


uploadJson

uploadJson(json, dst, options?): Promise<Result<any>>

Parameters

NameType
jsonany
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:154


uploadData

uploadData(data, dst, options?): Promise<Result<any>>

Parameters

NameType
dataUint8Array
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:159


downloadFile

downloadFile(src, dst, options?): Promise<Result<any>>

Parameters

NameType
srcstring
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:163


downloadData

downloadData(src, options?): Promise<Result<Uint8Array>>

Parameters

NameType
srcstring
options?CommandOptions

Returns

Promise<Result<Uint8Array>>

Defined in

src/task/work.ts:167


downloadJson

downloadJson(src, options?): Promise<Result<any>>

Parameters

NameType
srcstring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:172


beginBatch

beginBatch(): Batch

Returns

Batch

Defined in

src/task/work.ts:187


rejectResult

rejectResult(msg): void

Parameters

NameType
msgstring

Returns

void

Deprecated

This function is only used to throw errors from unit tests. It should be removed.

Defined in

src/task/work.ts:194


getWebsocketUri

getWebsocketUri(port): string

Parameters

NameType
portnumber

Returns

string

Defined in

src/task/work.ts:198


getIp

getIp(): string

Returns

string

Defined in

src/task/work.ts:203


getState

getState(): Promise<ActivityStateEnum>

Returns

Promise<ActivityStateEnum>

Defined in

src/task/work.ts:208