Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SASViyaApiClient

A client for interfacing with the SAS Viya REST API

Hierarchy

  • SASViyaApiClient

Constructors

constructor

  • new SASViyaApiClient(serverUrl: string, rootFolderName: string, rootFolderMap?: Map<string, Job[]>): SASViyaApiClient
  • Parameters

    • serverUrl: string
    • rootFolderName: string
    • Default value rootFolderMap: Map<string, Job[]> = new Map<string, Job[]>()

    Returns SASViyaApiClient

Methods

createFolder

  • createFolder(folderName: string, parentFolderPath?: undefined | string, parentFolderUri?: undefined | string, accessToken?: undefined | string): Promise<Folder>
  • Creates a folder in the specified location. Either parentFolderPath or parentFolderUri must be provided.

    Parameters

    • folderName: string

      the name of the new folder.

    • Optional parentFolderPath: undefined | string

      the full path to the parent folder. If not provided, the parentFolderUri must be provided.

    • Optional parentFolderUri: undefined | string

      the URI (eg /folders/folders/UUID) of the parent folder. If not provided, the parentFolderPath must be provided.

    • Optional accessToken: undefined | string

    Returns Promise<Folder>

createJobDefinition

  • createJobDefinition(jobName: string, code: string, parentFolderPath?: undefined | string, parentFolderUri?: undefined | string, accessToken?: undefined | string): Promise<Job>
  • Creates a Job in the specified folder (or folder uri).

    Parameters

    • jobName: string

      the name of the new job to be created.

    • code: string

      the SAS code for the new job.

    • Optional parentFolderPath: undefined | string

      the location of the new job.

    • Optional parentFolderUri: undefined | string

      the URI location of the new job. The function is a little faster if the folder URI is supplied instead of the path.

    • Optional accessToken: undefined | string

    Returns Promise<Job>

createSession

  • createSession(contextName: string, accessToken?: undefined | string): Promise<Session>
  • Creates a session on the given context.

    Parameters

    • contextName: string

      the name of the context to create a session on.

    • Optional accessToken: undefined | string

      an access token for an authorized user.

    Returns Promise<Session>

deleteClient

  • deleteClient(clientId: string, accessToken?: undefined | string): Promise<unknown>
  • Deletes the client representing the supplied ID.

    Parameters

    • clientId: string

      the client ID to authenticate with.

    • Optional accessToken: undefined | string

      an access token for an authorized user.

    Returns Promise<unknown>

executeJob

  • executeJob(sasJob: string, contextName: string, debug: boolean, data?: any, accessToken?: undefined | string): Promise<any>
  • Executes a job via the SAS Viya Job Execution API

    Parameters

    • sasJob: string

      the relative path to the job.

    • contextName: string

      the name of the context where the job is to be executed.

    • debug: boolean

      sets the _debug flag in the job arguments.

    • Optional data: any

      any data to be passed in as input to the job.

    • Optional accessToken: undefined | string

      an optional access token for an authorized user.

    Returns Promise<any>

executeScript

  • executeScript(fileName: string, linesOfCode: string[], contextName: string, accessToken?: undefined | string, sessionId?: string, silent?: boolean): Promise<undefined | object>
  • Executes code on the current SAS Viya server.

    Parameters

    • fileName: string

      a name for the file being submitted for execution.

    • linesOfCode: string[]

      an array of lines of code to execute.

    • contextName: string

      the context to execute the code in.

    • Optional accessToken: undefined | string

      an access token for an authorized user.

    • Default value sessionId: string = ""

      optional session ID to reuse.

    • Default value silent: boolean = false

      optional flag to turn of logging.

    Returns Promise<undefined | object>

getAccessToken

  • getAccessToken(clientId: string, clientSecret: string, authCode: string): Promise<any>
  • Exchanges the auth code for an access token for the given client.

    Parameters

    • clientId: string

      the client ID to authenticate with.

    • clientSecret: string

      the client secret to authenticate with.

    • authCode: string

      the auth code received from the server.

    Returns Promise<any>

getAllContexts

  • getAllContexts(accessToken?: undefined | string): Promise<object[]>
  • Returns all available compute contexts on this server.

    Parameters

    • Optional accessToken: undefined | string

      an access token for an authorized user.

    Returns Promise<object[]>

getAppLocMap

  • getAppLocMap(): Promise<Map<string, Job[]>>
  • Returns a map containing the directory structure in the currently set root folder.

    Returns Promise<Map<string, Job[]>>

getAuthCode

  • getAuthCode(clientId: string): Promise<null | string>
  • Performs a login redirect and returns an auth code for the given client

    Parameters

    • clientId: string

      the client ID to authenticate with.

    Returns Promise<null | string>

getConfig

  • getConfig(): object
  • returns an object containing the Server URL and root folder name

    Returns object

    • rootFolderName: string
    • serverUrl: string

getExecutableContexts

  • getExecutableContexts(accessToken?: undefined | string): Promise<any[]>
  • Returns all compute contexts on this server that the user has access to.

    Parameters

    • Optional accessToken: undefined | string

      an access token for an authorized user.

    Returns Promise<any[]>

refreshTokens

  • refreshTokens(clientId: string, clientSecret: string, refreshToken: string): Promise<any>
  • Exchanges the refresh token for an access token for the given client.

    Parameters

    • clientId: string

      the client ID to authenticate with.

    • clientSecret: string

      the client secret to authenticate with.

    • refreshToken: string

    Returns Promise<any>

setConfig

  • setConfig(serverUrl: string, rootFolderName: string): void
  • Updates server URL or root folder name when not null

    Parameters

    • serverUrl: string

      the URL of the server.

    • rootFolderName: string

      the name for rootFolderName.

    Returns void

Generated using TypeDoc