# Module api/viya

### Functions

- executeScript
- getFileStream
- pollJobState
- saveLog
- uploadTables
- writeStream

## Functions

### executeScript

- executeScript(requestClient: RequestClient, sessionManager: SessionManager, rootFolderName: string, jobPath: string, linesOfCode: string[], contextName: string, authConfig?: AuthConfig, data?: any, debug?: boolean, expectWebout?: boolean, waitForResult?: boolean, pollOptions?: PollOptions, printPid?: boolean, variables?: MacroVar): Promise<any>

- - Defined in src/api/viya/executeScript.ts:32

  Executes code on the current SAS Viya server.

  #### Parameters

  - ##### requestClient: RequestClient

  - ##### sessionManager: SessionManager

  - ##### rootFolderName: string

  - ##### jobPath: string

    the path to the file being submitted for execution.

  - ##### linesOfCode: string[]

    an array of code lines to execute.

  - ##### contextName: string

    the context to execute the code in.

  - ##### Optional authConfig: AuthConfig

    an object containing an access token, refresh token, client ID and secret.

  - ##### Default value data: any = null

    execution data.

  - ##### Default value debug: boolean = false

    when set to true, the log will be returned.

  - ##### Default value expectWebout: boolean = false

    when set to true, the automatic _webout fileref will be checked for content, and that content returned. This fileref is used when the Job contains a SASjs web request (as opposed to executing arbitrary SAS code).

  - ##### Default value waitForResult: boolean = true

    when set to true, function will return the session

  - ##### Optional pollOptions: PollOptions

    an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { MAX_POLL_COUNT: 24 * 60 * 60, POLL_INTERVAL: 1000 }.

  - ##### Default value printPid: boolean = false

    a boolean that indicates whether the function should print (PID) of the started job.

  - ##### Optional variables: MacroVar

    an object that represents macro variables.

  #### Returns Promise<any>

### Const getFileStream

- getFileStream(job: Job, filePath?: undefined | string): Promise<any>

- - Defined in src/api/viya/getFileStream.ts:5

  #### Parameters

  - ##### job: Job

  - ##### Optional filePath: undefined | string

  #### Returns Promise<any>

### pollJobState

- pollJobState(requestClient: RequestClient, postedJob: Job, debug: boolean, authConfig?: AuthConfig, pollOptions?: PollOptions): Promise<string>

- - Defined in src/api/viya/pollJobState.ts:9

  #### Parameters

  - ##### requestClient: RequestClient

  - ##### postedJob: Job

  - ##### debug: boolean

  - ##### Optional authConfig: AuthConfig

  - ##### Optional pollOptions: PollOptions

  #### Returns Promise<string>

### saveLog

- saveLog(job: Job, requestClient: RequestClient, startLine: number, endLine: number, logFileStream?: WriteStream, accessToken?: undefined | string): Promise<void>

- - Defined in src/api/viya/saveLog.ts:18

  Appends logs to a supplied write stream. This is useful for getting quick feedback on longer running jobs.

  accesstoken
    - an optional access token for authentication/authorization The access token is not required when fetching logs from the browser.

  #### Parameters

  - ##### job: Job

    the job to fetch logs for

  - ##### requestClient: RequestClient

    the pre-configured HTTP request client

  - ##### startLine: number

    the line at which to start fetching the log

  - ##### endLine: number

    the line at which to stop fetching the log

  - ##### Optional logFileStream: WriteStream

    the write stream to which the log is appended

  - ##### Optional accessToken: undefined | string

  #### Returns Promise<void>

### uploadTables

- uploadTables(requestClient: RequestClient, data: any, accessToken?: undefined | string): Promise<object[]>

- - Defined in src/api/viya/uploadTables.ts:13

  Uploads tables to SAS as specially formatted CSVs. This is more compact than JSON, and easier to read within SAS.

  #### Parameters

  - ##### requestClient: RequestClient

    the pre-configured HTTP request client

  - ##### data: any

    the JSON representation of the data to be uploaded

  - ##### Optional accessToken: undefined | string

    an optional access token for authentication/authorization The access token is not required when uploading tables from the browser.

  #### Returns Promise<object[]>

### Const writeStream

- writeStream(stream: WriteStream, content: string): Promise<void>

- - Defined in src/api/viya/writeStream.ts:3

  #### Parameters

  - ##### stream: WriteStream

  - ##### content: string

  #### Returns Promise<void>

Generated using TypeDoc