@sasjs/adapter
    Preparing search index...

    Class SASViyaApiClient

    A client for interfacing with the SAS Viya REST API.

    Index
    • Parameters

      • serverUrl: string
      • rootFolderName: string
      • contextName: string
      • requestClient: RequestClient

      Returns SASViyaApiClient

    • A helper method used to call appendRequest method of RequestClient

      Parameters

      • response: any

        response from sasjs request

      • program: string

        name of program

      • debug: boolean

        a boolean that indicates whether debug was enabled or not

      Returns void

    • Creates a compute context on the given server.

      Parameters

      • contextName: string

        the name of the context to be created.

      • launchContextName: string

        the name of the launcher context used by the compute service.

      • sharedAccountId: string

        the ID of the account to run the servers for this context.

      • autoExecLines: string[]

        the lines of code to execute during session initialization.

      • OptionalaccessToken: string

        an access token for an authorized user.

      • OptionalauthorizedUsers: string[]

        an optional list of authorized user IDs.

      Returns Promise<Context>

    • Creates a file. Path to or URI of the parent folder is required.

      Parameters

      • fileName: string

        the name of the new file.

      • contentBuffer: Buffer

        the content of the new file in Buffer.

      • OptionalparentFolderPath: string

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

      • OptionalparentFolderUri: string

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

      • OptionalaccessToken: string

        an access token for authorizing the request.

      Returns Promise<File>

    • Creates a folder. Path to or URI of the parent folder is required.

      Parameters

      • folderName: string

        the name of the new folder.

      • OptionalparentFolderPath: string

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

      • OptionalparentFolderUri: string

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

      • OptionalaccessToken: string

        an access token for authorizing the request.

      • OptionalisForced: boolean

        flag that indicates if target folder already exists, it and all subfolders have to be deleted.

      Returns Promise<Folder>

    • 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.

      • OptionalparentFolderPath: string

        the location of the new job.

      • OptionalparentFolderUri: string

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

      • OptionalaccessToken: string

      Returns Promise<{ etag: string; result: Job }>

    • Creates a launcher context on the given server.

      Parameters

      • contextName: string

        the name of the context to be created.

      • description: string

        the description of the context to be created.

      • launchType: string = 'direct'

        launch type of the context to be created.

      • OptionalaccessToken: string

        an access token for an authorized user.

      Returns Promise<Context>

    • Creates a session on the given context.

      Parameters

      • contextName: string

        the name of the context to create a session on.

      • OptionalaccessToken: string

        an access token for an authorized user.

      Returns Promise<Session>

    • Deletes the client representing the supplied ID.

      Parameters

      • clientId: string

        the client ID to authenticate with.

      • OptionalaccessToken: string

        an access token for authorizing the request.

      Returns Promise<unknown>

    • Deletes a compute context on the given server.

      Parameters

      • contextName: string

        the name of the context to be deleted.

      • OptionalaccessToken: string

        an access token for an authorized user.

      Returns Promise<{ etag: string; result: Context }>

    • For performance (and in case of accidental error) the deleteFolder function does not actually delete the folder (and all its content and subfolder content). Instead the folder is simply moved to the recycle bin. Deletion time will be added to the folder name.

      Parameters

      • folderPath: string

        the full path (eg /Public/example/deleteThis) of the folder to be deleted.

      • OptionalaccessToken: string

        an access token for authorizing the request.

      Returns Promise<Folder | undefined>

    • Updates a compute context on the given server.

      Parameters

      • contextName: string

        the original name of the context to be updated.

      • editedContext: EditContextInput

        an object with the properties to be updated.

      • OptionalaccessToken: string

        an access token for an authorized user.

      Returns Promise<{ etag: string; result: Context }>

    • Executes a job via the SAS Viya Compute API.

      Parameters

      • sasJob: string

        the relative path to the job.

      • contextName: string

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

      • Optionaldebug: boolean

        sets the _debug flag in the job arguments.

      • Optionaldata: any

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

      • OptionalauthConfig: AuthConfig
      • waitForResult: boolean = true

        a boolean indicating if the function should wait for a result.

      • expectWebout: boolean = false

        a boolean indicating whether to expect a _webout response.

      • OptionalpollOptions: PollOptions

        an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { maxPollCount: 24 * 60 * 60, pollInterval: 1000 }. More information available at src/api/viya/pollJobState.ts.

      • printPid: boolean = false

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

      • Optionalvariables: MacroVar

        an object that represents macro variables.

      • OptionalonTokensRefreshed: OnTokensRefreshed

      Returns Promise<any>

    • Executes a job via the SAS Viya Job Execution API

      Parameters

      • sasJob: string

        the relative or absolute 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.

      • Optionaldata: any

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

      • OptionalauthConfig: AuthConfig
      • OptionalonTokensRefreshed: OnTokensRefreshed

        optional callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.

      Returns Promise<JobExecutionResult>

    • Executes code on the current SAS Viya server.

      Parameters

      • 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.

      • OptionalauthConfig: AuthConfig

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

      • data: null = null

        execution data.

      • debug: boolean = false

        when set to true, the log will be returned.

      • 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).

      • waitForResult: boolean = true

        when set to true, function will return the session

      • OptionalpollOptions: PollOptions

        an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { maxPollCount: 24 * 60 * 60, pollInterval: 1000 }. More information available at src/api/viya/pollJobState.ts.

      • printPid: boolean = false

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

      • Optionalvariables: MacroVar

        an object that represents macro variables.

      • OptionalonTokensRefreshed: OnTokensRefreshed

        optional callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.

      Returns 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<SasAuthResponse>

    • Performs a login redirect and returns an auth code for the given client.

      Parameters

      • clientId: string

        the client ID to authenticate with.

      Returns Promise<string | null>

    • Returns a JSON representation of a compute context.

      Parameters

      • contextId: string

        an id of the context to return.

      • OptionalaccessToken: string

        an access token for an authorized user.

      Returns Promise<ContextAllAttributes>

    • Returns a JSON representation of a compute context. @example: { "createdBy": "admin", "links": [...], "id": "ID", "version": 2, "name": "context1" }

      Parameters

      • contextName: string

        the name of the context to return.

      • OptionalaccessToken: string

        an access token for an authorized user.

      Returns Promise<Context>

    • Returns all available compute contexts on this server.

      Parameters

      • OptionalaccessToken: string

        an access token for an authorized user.

      Returns Promise<{ attributes: {}; createdBy: any; id: any; name: any; version: any }[]>

    • Returns an object containing the server URL and root folder name.

      Returns { rootFolderName: string; serverUrl: string }

    • Returns default(system) compute contexts.

      Returns string[]

    • Returns all compute contexts on this server that the user has access to.

      Parameters

      • OptionalauthConfig: AuthConfig

        an access token, refresh token, client and secret for an authorized user.

      Returns Promise<any[]>

    • Fetches the file content for a file in the specified folder.

      Parameters

      • folderPath: string

        the full path to the folder containing the file. eg: /Public/folder1/folder2

      • fileName: string

        the name of the file in the folderPath

      • OptionalaccessToken: string

        an access token for authorizing the request

      Returns Promise<string>

    • Fetches a folder. Path to the folder is required.

      Parameters

      • folderPath: string

        the absolute path to the folder.

      • OptionalaccessToken: string

        an access token for authorizing the request.

      Returns Promise<unknown>

    • Returns a list of jobs in the currently set root folder.

      Parameters

      • folderPath: string

      Returns Promise<Job[] | undefined>

    • Returns all available launcher contexts on this server.

      Parameters

      • OptionalaccessToken: string

        an access token for an authorized user.

      Returns Promise<{ attributes: {}; createdBy: any; id: any; name: any; version: any }[]>

    • Lists children folders/files for given Viya folder.

      Parameters

      • sourceFolder: string

        the full path (eg /Public/example/myFolder) or URI of the source folder listed. Providing URI instead of path will save one extra request.

      • OptionalaccessToken: string

        an access token for authorizing the request.

      • limit: number = 20
      • Optionaloptions: { returnDetails?: boolean }

        Additional options.

        • OptionalreturnDetails?: boolean

          when set to true, the function will return an array of objects with member details, otherwise it will return an array of member names.

      Returns Promise<any[]>

    • Moves Viya folder to a new location. The folder may be renamed at the same time.

      Parameters

      • sourceFolder: string

        the full path (eg /Public/example/myFolder) or URI of the source folder to be moved. Providing URI instead of path will save one extra request.

      • targetParentFolder: string

        the full path or URI of the parent folder to which the sourceFolder will be moved (eg /Public/newDestination). To move a folder, a user has to have write permissions in targetParentFolder. Providing URI instead of the path will save one extra request.

      • targetFolderName: string

        the name of the "moved" folder. If left blank, the original folder name will be used (eg myFolder in /Public/newDestination/myFolder for the example above). Optional field.

      • OptionalaccessToken: string

        an access token for authorizing the request.

      Returns Promise<Folder | undefined>

    • Exchanges the refresh token for an access token for the given client. This method can only be used by Node.

      Parameters

      • clientId: string

        the client ID to authenticate with.

      • clientSecret: string

        the client secret to authenticate with.

      • refreshToken: string

        the refresh token received from the server.

      Returns Promise<SasAuthResponse>

    • Updates server URL and root folder name, if it was not set.

      Parameters

      • serverUrl: string

        the URL of the server.

      • rootFolderName: string

        the name for root folder.

      Returns void

    • Updates the file content for a file in the specified folder.

      Parameters

      • folderPath: string

        the full path to the folder containing the file. eg: /Public/folder1/folder2

      • fileName: string

        the name of the file in the folderPath

      • content: string

        the new content to be written to the file

      • OptionalaccessToken: string

        an access token for authorizing the request

      Returns Promise<FileResource>