mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-16 08:30:07 +00:00
fix(create-context): change autoExecLines to an array
This commit is contained in:
@@ -191,7 +191,7 @@ export class SASViyaApiClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a compute context on the given server.
|
* Creates a compute context on the given server.
|
||||||
* @param contextName - the name of the context to create a session on.
|
* @param contextName - the name of the context to be created.
|
||||||
* @param launchContextName - the name of the launcher context used by the compute service.
|
* @param launchContextName - the name of the launcher context used by the compute service.
|
||||||
* @param sharedAccountId - the ID of the account to run the servers for this context as.
|
* @param sharedAccountId - the ID of the account to run the servers for this context as.
|
||||||
* @param autoExecLines - the lines of code to execute during session initialization.
|
* @param autoExecLines - the lines of code to execute during session initialization.
|
||||||
@@ -202,7 +202,7 @@ export class SASViyaApiClient {
|
|||||||
contextName: string,
|
contextName: string,
|
||||||
launchContextName: string,
|
launchContextName: string,
|
||||||
sharedAccountId: string,
|
sharedAccountId: string,
|
||||||
autoExecLines: string,
|
autoExecLines: string[],
|
||||||
authorizedUsers: string[],
|
authorizedUsers: string[],
|
||||||
accessToken?: string
|
accessToken?: string
|
||||||
) {
|
) {
|
||||||
@@ -228,9 +228,6 @@ export class SASViyaApiClient {
|
|||||||
|
|
||||||
const requestBody: any = {
|
const requestBody: any = {
|
||||||
name: contextName,
|
name: contextName,
|
||||||
environment: {
|
|
||||||
autoExecLines: autoExecLines || ''
|
|
||||||
},
|
|
||||||
launchContext: {
|
launchContext: {
|
||||||
contextName: launchContextName
|
contextName: launchContextName
|
||||||
},
|
},
|
||||||
@@ -246,6 +243,12 @@ export class SASViyaApiClient {
|
|||||||
requestBody['authorizeAllAuthenticatedUsers'] = true
|
requestBody['authorizeAllAuthenticatedUsers'] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (autoExecLines) {
|
||||||
|
requestBody.environment = { autoExecLines }
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Body', requestBody)
|
||||||
|
|
||||||
const createContextRequest: RequestInit = {
|
const createContextRequest: RequestInit = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers,
|
headers,
|
||||||
@@ -260,6 +263,35 @@ export class SASViyaApiClient {
|
|||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a compute context on the given server.
|
||||||
|
* @param contextId - the ID of the context to be deleted.
|
||||||
|
* @param accessToken - an access token for an authorized user.
|
||||||
|
*/
|
||||||
|
public async deleteContext(contextId: string, accessToken?: string) {
|
||||||
|
if (!contextId) {
|
||||||
|
throw new Error('Invalid context ID')
|
||||||
|
}
|
||||||
|
|
||||||
|
const headers: any = {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accessToken) {
|
||||||
|
headers.Authorization = `Bearer ${accessToken}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteContextRequest: RequestInit = {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers
|
||||||
|
}
|
||||||
|
|
||||||
|
return await this.request<Context>(
|
||||||
|
`${this.serverUrl}/compute/contexts/${contextId}`,
|
||||||
|
deleteContextRequest
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes code on the current SAS Viya server.
|
* Executes code on the current SAS Viya server.
|
||||||
* @param fileName - a name for the file being submitted for execution.
|
* @param fileName - a name for the file being submitted for execution.
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export default class SASjs {
|
|||||||
contextName: string,
|
contextName: string,
|
||||||
launchContextName: string,
|
launchContextName: string,
|
||||||
sharedAccountId: string,
|
sharedAccountId: string,
|
||||||
autoExecLines: string,
|
autoExecLines: string[],
|
||||||
authorizedUsers: string[],
|
authorizedUsers: string[],
|
||||||
accessToken: string
|
accessToken: string
|
||||||
) {
|
) {
|
||||||
@@ -128,6 +128,13 @@ export default class SASjs {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async deleteContext(contextId: string) {
|
||||||
|
if (this.sasjsConfig.serverType !== ServerType.SASViya) {
|
||||||
|
throw new Error('This operation is only supported on SAS Viya servers.')
|
||||||
|
}
|
||||||
|
return await this.sasViyaApiClient!.deleteContext(contextId)
|
||||||
|
}
|
||||||
|
|
||||||
public async createSession(contextName: string, accessToken: string) {
|
public async createSession(contextName: string, accessToken: string) {
|
||||||
if (this.sasjsConfig.serverType !== ServerType.SASViya) {
|
if (this.sasjsConfig.serverType !== ServerType.SASViya) {
|
||||||
throw new Error('This operation is only supported on SAS Viya servers.')
|
throw new Error('This operation is only supported on SAS Viya servers.')
|
||||||
|
|||||||
Reference in New Issue
Block a user