1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-09 13:30:04 +00:00

chore: fixing useComputeApi defaults

This commit is contained in:
2021-06-22 16:51:14 +02:00
parent abc15fb3ab
commit 5d7cfe1e6c
3 changed files with 13 additions and 17 deletions

View File

@@ -38,12 +38,7 @@ export class FileUploader {
: sasJob : sasJob
const uploadUrl = `${this.jobsPath}/?${ const uploadUrl = `${this.jobsPath}/?${
'_program=' + program '_program=' + program
}${paramsString}${ }${paramsString}`
this.sasjsConfig.serverType === ServerType.SasViya &&
this.sasjsConfig.contextName
? '&_contextname=' + this.sasjsConfig.contextName
: ''
}`
const formData = new FormData() const formData = new FormData()
@@ -54,6 +49,7 @@ export class FileUploader {
const csrfToken = this.requestClient.getCsrfToken('file') const csrfToken = this.requestClient.getCsrfToken('file')
if (csrfToken) formData.append('_csrf', csrfToken.value) if (csrfToken) formData.append('_csrf', csrfToken.value)
if (this.sasjsConfig.debug) formData.append('_debug', '131') if (this.sasjsConfig.debug) formData.append('_debug', '131')
if (this.sasjsConfig.serverType === ServerType.SasViya && this.sasjsConfig.contextName) formData.append('_contextname', this.sasjsConfig.contextName)
const headers = { const headers = {
'cache-control': 'no-cache', 'cache-control': 'no-cache',
@@ -63,8 +59,12 @@ export class FileUploader {
return this.requestClient return this.requestClient
.post(uploadUrl, formData, undefined, 'application/json', headers) .post(uploadUrl, formData, undefined, 'application/json', headers)
.then((res) => .then((res) => {
typeof res.result === 'string' ? JSON.parse(res.result) : res.result let result
result = typeof res.result === 'string' ? JSON.parse(res.result) : res.result
//TODO: append to SASjs requests
}
) )
.catch((err: Error) => { .catch((err: Error) => {
if (err instanceof LoginRequiredError) { if (err instanceof LoginRequiredError) {

View File

@@ -24,7 +24,7 @@ const defaultConfig: SASjsConfig = {
serverType: ServerType.SasViya, serverType: ServerType.SasViya,
debug: false, debug: false,
contextName: 'SAS Job Execution compute context', contextName: 'SAS Job Execution compute context',
useComputeApi: false, useComputeApi: null,
allowInsecureRequests: false allowInsecureRequests: false
} }

View File

@@ -40,23 +40,19 @@ export class SASjsConfig {
*/ */
debug: boolean = true debug: boolean = true
/** /**
* The name of the compute context to use when calling the Viya APIs directly. * The name of the compute context to use when calling the Viya services directly.
* Example value: 'SAS Job Execution compute context' * Example value: 'SAS Job Execution compute context'
* If set to missing or empty, and useComputeApi is true, the adapter will use
* the JES APIs. If provided, the Job Code will be executed in pooled
* compute sessions on this named context.
*/ */
contextName: string = '' contextName: string = ''
/** /**
* Set to `false` to use the Job Execution Web Service. To enhance VIYA * If it's `false` adapter will use the JES API as connection approach. To enhance VIYA
* performance, set to `true` and provide a `contextName` on which to run * performance, set to `true` and provide a `contextName` on which to run
* the code. When running on a named context, the code executes under the * the code. When running on a named context, the code executes under the
* user identity. When running as a Job Execution service, the code runs * user identity. When running as a Job Execution service, the code runs
* under the identity in the JES context. If no `contextName` is provided, * under the identity in the JES context. If `useComputeApi` is `null` or `undefined`, the service will run as a Job, except
* and `useComputeApi` is `true`, then the service will run as a Job, except
* triggered using the APIs instead of the Job Execution Web Service broker. * triggered using the APIs instead of the Job Execution Web Service broker.
*/ */
useComputeApi = false useComputeApi: boolean | null = null
/** /**
* Defaults to `false`. * Defaults to `false`.
* When set to `true`, the adapter will allow requests to SAS servers that use a self-signed SSL certificate. * When set to `true`, the adapter will allow requests to SAS servers that use a self-signed SSL certificate.