mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-11 09:24:35 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8467c24b1 | ||
|
|
fc9056c1ac | ||
|
|
9b1d295b82 | ||
|
|
99d0b01a24 | ||
|
|
131c672020 | ||
|
|
338f2fb2dd | ||
|
|
4552a9a856 | ||
|
|
daeb753f9e | ||
|
|
f50a99d0b8 | ||
|
|
e6d0d3efd5 | ||
|
|
057460467c | ||
|
|
5aee9d955e | ||
|
|
7fb1da31e4 | ||
|
|
1aa92c0a69 | ||
|
|
4c097a69fd | ||
|
|
2634933e84 | ||
|
|
d60c0850c2 | ||
|
|
491bc3371c | ||
|
|
c1bab07b08 | ||
|
|
95f3ebd51d | ||
|
|
0e5b72b54f | ||
|
|
9f6591d7e3 | ||
|
|
5343ca00d8 |
17
PULL_REQUEST_TEMPLATE.md
Normal file
17
PULL_REQUEST_TEMPLATE.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## Issue
|
||||
|
||||
Link any related issue(s) in this section.
|
||||
|
||||
## Intent
|
||||
|
||||
What this PR intends to achieve.
|
||||
|
||||
## Implementation
|
||||
|
||||
What code changes have been made to achieve the intent.
|
||||
|
||||
## Checks
|
||||
|
||||
- [ ] Code is formatted correctly (`npm run lint:fix`).
|
||||
- [ ] All unit tests are passing (`npm test`).
|
||||
- [ ] All `sasjs-tests` are passing (instructions available [here](https://github.com/sasjs/adapter/blob/master/sasjs-tests/README.md)).
|
||||
File diff suppressed because one or more lines are too long
231
docs/classes/reflection-734.reflection-194.fileuploader.html
Normal file
231
docs/classes/reflection-734.reflection-194.fileuploader.html
Normal file
File diff suppressed because one or more lines are too long
312
docs/classes/reflection-734.reflection-194.sas9apiclient.html
Normal file
312
docs/classes/reflection-734.reflection-194.sas9apiclient.html
Normal file
File diff suppressed because one or more lines are too long
1385
docs/classes/reflection-734.reflection-194.sasjs.html
Normal file
1385
docs/classes/reflection-734.reflection-194.sasjs.html
Normal file
File diff suppressed because one or more lines are too long
1350
docs/classes/reflection-734.reflection-194.sasviyaapiclient.html
Normal file
1350
docs/classes/reflection-734.reflection-194.sasviyaapiclient.html
Normal file
File diff suppressed because one or more lines are too long
271
docs/classes/reflection-734.reflection-194.sessionmanager.html
Normal file
271
docs/classes/reflection-734.reflection-194.sessionmanager.html
Normal file
File diff suppressed because one or more lines are too long
231
docs/classes/reflection-743.reflection-195.fileuploader.html
Normal file
231
docs/classes/reflection-743.reflection-195.fileuploader.html
Normal file
File diff suppressed because one or more lines are too long
312
docs/classes/reflection-743.reflection-195.sas9apiclient.html
Normal file
312
docs/classes/reflection-743.reflection-195.sas9apiclient.html
Normal file
File diff suppressed because one or more lines are too long
1419
docs/classes/reflection-743.reflection-195.sasjs.html
Normal file
1419
docs/classes/reflection-743.reflection-195.sasjs.html
Normal file
File diff suppressed because one or more lines are too long
1415
docs/classes/reflection-743.reflection-195.sasviyaapiclient.html
Normal file
1415
docs/classes/reflection-743.reflection-195.sasviyaapiclient.html
Normal file
File diff suppressed because one or more lines are too long
271
docs/classes/reflection-743.reflection-195.sessionmanager.html
Normal file
271
docs/classes/reflection-743.reflection-195.sessionmanager.html
Normal file
File diff suppressed because one or more lines are too long
231
docs/classes/reflection-759.reflection-211.fileuploader.html
Normal file
231
docs/classes/reflection-759.reflection-211.fileuploader.html
Normal file
File diff suppressed because one or more lines are too long
312
docs/classes/reflection-759.reflection-211.sas9apiclient.html
Normal file
312
docs/classes/reflection-759.reflection-211.sas9apiclient.html
Normal file
File diff suppressed because one or more lines are too long
1430
docs/classes/reflection-759.reflection-211.sasjs.html
Normal file
1430
docs/classes/reflection-759.reflection-211.sasjs.html
Normal file
File diff suppressed because one or more lines are too long
1395
docs/classes/reflection-759.reflection-211.sasviyaapiclient.html
Normal file
1395
docs/classes/reflection-759.reflection-211.sasviyaapiclient.html
Normal file
File diff suppressed because one or more lines are too long
271
docs/classes/reflection-759.reflection-211.sessionmanager.html
Normal file
271
docs/classes/reflection-759.reflection-211.sessionmanager.html
Normal file
File diff suppressed because one or more lines are too long
231
docs/classes/reflection-762.reflection-214.fileuploader.html
Normal file
231
docs/classes/reflection-762.reflection-214.fileuploader.html
Normal file
File diff suppressed because one or more lines are too long
312
docs/classes/reflection-762.reflection-214.sas9apiclient.html
Normal file
312
docs/classes/reflection-762.reflection-214.sas9apiclient.html
Normal file
File diff suppressed because one or more lines are too long
1430
docs/classes/reflection-762.reflection-214.sasjs.html
Normal file
1430
docs/classes/reflection-762.reflection-214.sasjs.html
Normal file
File diff suppressed because one or more lines are too long
1395
docs/classes/reflection-762.reflection-214.sasviyaapiclient.html
Normal file
1395
docs/classes/reflection-762.reflection-214.sasviyaapiclient.html
Normal file
File diff suppressed because one or more lines are too long
271
docs/classes/reflection-762.reflection-214.sessionmanager.html
Normal file
271
docs/classes/reflection-762.reflection-214.sessionmanager.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
398
docs/interfaces/types.contextallattributes.html
Normal file
398
docs/interfaces/types.contextallattributes.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
106
docs/modules/reflection-734.html
Normal file
106
docs/modules/reflection-734.html
Normal file
File diff suppressed because one or more lines are too long
128
docs/modules/reflection-734.reflection-194.html
Normal file
128
docs/modules/reflection-734.reflection-194.html
Normal file
File diff suppressed because one or more lines are too long
106
docs/modules/reflection-743.html
Normal file
106
docs/modules/reflection-743.html
Normal file
File diff suppressed because one or more lines are too long
128
docs/modules/reflection-743.reflection-195.html
Normal file
128
docs/modules/reflection-743.reflection-195.html
Normal file
File diff suppressed because one or more lines are too long
106
docs/modules/reflection-759.html
Normal file
106
docs/modules/reflection-759.html
Normal file
File diff suppressed because one or more lines are too long
128
docs/modules/reflection-759.reflection-211.html
Normal file
128
docs/modules/reflection-759.reflection-211.html
Normal file
File diff suppressed because one or more lines are too long
106
docs/modules/reflection-762.html
Normal file
106
docs/modules/reflection-762.html
Normal file
File diff suppressed because one or more lines are too long
128
docs/modules/reflection-762.reflection-214.html
Normal file
128
docs/modules/reflection-762.reflection-214.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -30,8 +30,8 @@
|
||||
$('#chart-container').append('<canvas id="myChart" style="display: none;"></canvas>')
|
||||
// make a request to a SAS service
|
||||
var type = $("#cars")[0].options[$("#cars")[0].selectedIndex].value;
|
||||
// request data from an endpoint under your appLoc
|
||||
sasJs.request("/common/getdata", {
|
||||
// request data from an endpoint under your appLoc (missing opening slash implies relative path)
|
||||
sasJs.request("common/getdata", {
|
||||
// send data as an array of objects - each object is one row
|
||||
fromjs: [{ type: type }]
|
||||
}).then((response) => {
|
||||
|
||||
6
sasjs-tests/package-lock.json
generated
6
sasjs-tests/package-lock.json
generated
@@ -1357,9 +1357,9 @@
|
||||
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw=="
|
||||
},
|
||||
"@sasjs/adapter": {
|
||||
"version": "1.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@sasjs/adapter/-/adapter-1.3.13.tgz",
|
||||
"integrity": "sha512-dWcDxgY3FB7Yx1I5dPpeQeyJDu4lezhIFrjn6lbdwRhV15aqOt4l9o9qZP+VbgOXqyi9gN0Y+p+vs2chBDFQqg==",
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@sasjs/adapter/-/adapter-1.12.0.tgz",
|
||||
"integrity": "sha512-0uGQH9ynomWzdBaEujEtcR38q6V7LCgG0mrb1Wellv6cC/IHD3j6WfeZZAgtiMPeOSJjbCDBOlVnzC2TlBqJFw==",
|
||||
"requires": {
|
||||
"es6-promise": "^4.2.8",
|
||||
"form-data": "^3.0.0",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"homepage": ".",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@sasjs/adapter": "^1.3.13",
|
||||
"@sasjs/adapter": "^1.12.0",
|
||||
"@sasjs/test-framework": "^1.4.0",
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.5.0",
|
||||
|
||||
@@ -88,7 +88,7 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
return adapter.request("common/sendArr", data).catch((e) => e);
|
||||
},
|
||||
assertion: (error: any) => {
|
||||
return !!error && !!error.MESSAGE;
|
||||
return !!error && !!error.body && !!error.body.message;
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -185,7 +185,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
};
|
||||
return adapter.request("common/sendObj", invalidData).catch((e) => e);
|
||||
},
|
||||
assertion: (error: any) => !!error && !!error.MESSAGE
|
||||
assertion: (error: any) => !!error && !!error.body && !!error.body.message
|
||||
},
|
||||
{
|
||||
title: "Single string value",
|
||||
@@ -219,7 +219,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
.catch((e) => e);
|
||||
},
|
||||
assertion: (error: any) => {
|
||||
return !!error && !!error.MESSAGE;
|
||||
return !!error && !!error.body && !!error.body.message;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
Job,
|
||||
Session,
|
||||
Context,
|
||||
ContextAllAttributes,
|
||||
Folder,
|
||||
CsrfToken,
|
||||
EditContextInput,
|
||||
@@ -36,12 +37,12 @@ export class SASViyaApiClient {
|
||||
}
|
||||
|
||||
private csrfToken: CsrfToken | null = null
|
||||
private fileUploadCsrfToken: CsrfToken | null = null
|
||||
private sessionManager = new SessionManager(
|
||||
this.serverUrl,
|
||||
this.contextName,
|
||||
this.setCsrfToken
|
||||
)
|
||||
private isForceDeploy: boolean = false
|
||||
private folderMap = new Map<string, Job[]>()
|
||||
|
||||
/**
|
||||
@@ -223,16 +224,16 @@ export class SASViyaApiClient {
|
||||
* @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.
|
||||
* @param autoExecLines - the lines of code to execute during session initialization.
|
||||
* @param authorizedUsers - an optional list of authorized user IDs.
|
||||
* @param accessToken - an access token for an authorized user.
|
||||
* @param authorizedUsers - an optional list of authorized user IDs.
|
||||
*/
|
||||
public async createContext(
|
||||
contextName: string,
|
||||
launchContextName: string,
|
||||
sharedAccountId: string,
|
||||
autoExecLines: string[],
|
||||
authorizedUsers: string[],
|
||||
accessToken?: string
|
||||
accessToken?: string,
|
||||
authorizedUsers?: string[]
|
||||
) {
|
||||
if (!contextName) {
|
||||
throw new Error('Context name is required.')
|
||||
@@ -312,10 +313,22 @@ export class SASViyaApiClient {
|
||||
headers.Authorization = `Bearer ${accessToken}`
|
||||
}
|
||||
|
||||
const originalContext = await this.getContextByName(
|
||||
let originalContext
|
||||
|
||||
originalContext = await this.getComputeContextByName(
|
||||
contextName,
|
||||
accessToken
|
||||
)
|
||||
).catch((_) => {})
|
||||
|
||||
// Try to find context by id, when context name has been changed.
|
||||
if (!originalContext) {
|
||||
originalContext = await this.getComputeContextById(
|
||||
editedContext.id!,
|
||||
accessToken
|
||||
).catch((err) => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
const { result: context, etag } = await this.request<Context>(
|
||||
`${this.serverUrl}/compute/contexts/${originalContext.id}`,
|
||||
@@ -371,7 +384,7 @@ export class SASViyaApiClient {
|
||||
headers.Authorization = `Bearer ${accessToken}`
|
||||
}
|
||||
|
||||
const context = await this.getContextByName(contextName, accessToken)
|
||||
const context = await this.getComputeContextByName(contextName, accessToken)
|
||||
|
||||
const deleteContextRequest: RequestInit = {
|
||||
method: 'DELETE',
|
||||
@@ -611,8 +624,6 @@ export class SASViyaApiClient {
|
||||
if (!parentFolderUri && parentFolderPath) {
|
||||
parentFolderUri = await this.getFolderUri(parentFolderPath, accessToken)
|
||||
if (!parentFolderUri) {
|
||||
if (isForced) this.isForceDeploy = true
|
||||
|
||||
console.log(
|
||||
`Parent folder at path '${parentFolderPath}' is not present.`
|
||||
)
|
||||
@@ -638,37 +649,16 @@ export class SASViyaApiClient {
|
||||
`Parent folder '${newFolderName}' has been successfully created.`
|
||||
)
|
||||
parentFolderUri = `/folders/folders/${parentFolder.id}`
|
||||
} else if (isForced && accessToken && !this.isForceDeploy) {
|
||||
this.isForceDeploy = true
|
||||
} else if (isForced && accessToken) {
|
||||
const folderPath = parentFolderPath + '/' + folderName
|
||||
const folderUri = await this.getFolderUri(folderPath, accessToken)
|
||||
|
||||
await this.deleteFolder(parentFolderPath, accessToken)
|
||||
|
||||
const newParentFolderPath = parentFolderPath.substring(
|
||||
0,
|
||||
parentFolderPath.lastIndexOf('/')
|
||||
)
|
||||
const newFolderName = `${parentFolderPath.split('/').pop()}`
|
||||
|
||||
if (newParentFolderPath === '') {
|
||||
throw new Error(`Root folder has to be present on the server.`)
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Creating parent folder:\n'${newFolderName}' in '${newParentFolderPath}'`
|
||||
)
|
||||
|
||||
const parentFolder = await this.createFolder(
|
||||
newFolderName,
|
||||
newParentFolderPath,
|
||||
undefined,
|
||||
if (folderUri) {
|
||||
await this.deleteFolder(
|
||||
parentFolderPath + '/' + folderName,
|
||||
accessToken
|
||||
)
|
||||
|
||||
console.log(
|
||||
`Parent folder '${newFolderName}' has been successfully created.`
|
||||
)
|
||||
|
||||
parentFolderUri = `/folders/folders/${parentFolder.id}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -931,7 +921,10 @@ export class SASViyaApiClient {
|
||||
|
||||
if (isRelativePath(sasJob)) {
|
||||
const folderName = sasJob.split('/')[0]
|
||||
await this.populateFolderMap(`${this.rootFolderName}/${folderName}`)
|
||||
await this.populateFolderMap(
|
||||
`${this.rootFolderName}/${folderName}`,
|
||||
accessToken
|
||||
)
|
||||
|
||||
if (!this.folderMap.get(`${this.rootFolderName}/${folderName}`)) {
|
||||
throw new Error(
|
||||
@@ -1028,7 +1021,10 @@ export class SASViyaApiClient {
|
||||
|
||||
if (isRelativePath(sasJob)) {
|
||||
const folderName = sasJob.split('/')[0]
|
||||
await this.populateFolderMap(`${this.rootFolderName}/${folderName}`)
|
||||
await this.populateFolderMap(
|
||||
`${this.rootFolderName}/${folderName}`,
|
||||
accessToken
|
||||
)
|
||||
|
||||
if (!this.folderMap.get(`${this.rootFolderName}/${folderName}`)) {
|
||||
throw new Error(
|
||||
@@ -1335,7 +1331,9 @@ export class SASViyaApiClient {
|
||||
|
||||
const uploadResponse = await this.request<any>(
|
||||
`${this.serverUrl}/files/files#rawUpload`,
|
||||
createFileRequest
|
||||
createFileRequest,
|
||||
'json',
|
||||
'fileUpload'
|
||||
)
|
||||
|
||||
uploadedFiles.push({ tableName, file: uploadResponse.result })
|
||||
@@ -1384,7 +1382,13 @@ export class SASViyaApiClient {
|
||||
return `/folders/folders/${folder.id}`
|
||||
}
|
||||
|
||||
private async getContextByName(
|
||||
/**
|
||||
* Returns a JSON representation of a compute context.
|
||||
* @example: { "createdBy": "admin", "links": [...], "id": "ID", "version": 2, "name": "context1" }
|
||||
* @param contextName - the name of the context to return.
|
||||
* @param accessToken - an access token for an authorized user.
|
||||
*/
|
||||
public async getComputeContextByName(
|
||||
contextName: string,
|
||||
accessToken?: string
|
||||
): Promise<Context> {
|
||||
@@ -1399,9 +1403,7 @@ export class SASViyaApiClient {
|
||||
const { result: contexts } = await this.request<{ items: Context[] }>(
|
||||
`${this.serverUrl}/compute/contexts?filter=eq(name, "${contextName}")`,
|
||||
{ headers }
|
||||
).catch((err) => {
|
||||
throw err
|
||||
})
|
||||
)
|
||||
|
||||
if (!contexts || !(contexts.items && contexts.items.length)) {
|
||||
throw new Error(
|
||||
@@ -1412,6 +1414,33 @@ export class SASViyaApiClient {
|
||||
return contexts.items[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON representation of a compute context.
|
||||
* @param contextId - an id of the context to return.
|
||||
* @param accessToken - an access token for an authorized user.
|
||||
*/
|
||||
public async getComputeContextById(
|
||||
contextId: string,
|
||||
accessToken?: string
|
||||
): Promise<ContextAllAttributes> {
|
||||
const headers: any = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
if (accessToken) {
|
||||
headers.Authorization = `Bearer ${accessToken}`
|
||||
}
|
||||
|
||||
const { result: context } = await this.request<ContextAllAttributes>(
|
||||
`${this.serverUrl}/compute/contexts/${contextId}`,
|
||||
{ headers }
|
||||
).catch((err) => {
|
||||
throw err
|
||||
})
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a Viya folder to a new location. The folder may be renamed at the same time.
|
||||
* @param sourceFolder - 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.
|
||||
@@ -1455,6 +1484,16 @@ export class SASViyaApiClient {
|
||||
`${this.serverUrl}${url}`,
|
||||
requestInfo
|
||||
).catch((err) => {
|
||||
if (err.code && err.code === 'ENOTFOUND') {
|
||||
const notFoundError = {
|
||||
body: JSON.stringify({
|
||||
message: `Folder '${sourceFolder.split('/').pop()}' was not found.`
|
||||
})
|
||||
}
|
||||
|
||||
throw notFoundError
|
||||
}
|
||||
|
||||
throw err
|
||||
})
|
||||
|
||||
@@ -1490,22 +1529,36 @@ export class SASViyaApiClient {
|
||||
this.setCsrfToken(csrfToken)
|
||||
}
|
||||
|
||||
setFileUploadCsrfToken = (csrfToken: CsrfToken) => {
|
||||
this.fileUploadCsrfToken = csrfToken
|
||||
}
|
||||
|
||||
private async request<T>(
|
||||
url: string,
|
||||
options: RequestInit,
|
||||
contentType: 'text' | 'json' = 'json'
|
||||
contentType: 'text' | 'json' = 'json',
|
||||
type: 'fileUpload' | 'other' = 'other'
|
||||
) {
|
||||
const callback =
|
||||
type === 'fileUpload'
|
||||
? this.setFileUploadCsrfToken
|
||||
: this.setCsrfTokenLocal
|
||||
|
||||
if (type === 'other') {
|
||||
if (this.csrfToken) {
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
[this.csrfToken.headerName]: this.csrfToken.value
|
||||
}
|
||||
}
|
||||
return await makeRequest<T>(
|
||||
url,
|
||||
options,
|
||||
this.setCsrfTokenLocal,
|
||||
contentType
|
||||
)
|
||||
} else {
|
||||
if (this.fileUploadCsrfToken) {
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
[this.fileUploadCsrfToken.headerName]: this.fileUploadCsrfToken.value
|
||||
}
|
||||
}
|
||||
}
|
||||
return await makeRequest<T>(url, options, callback, contentType)
|
||||
}
|
||||
}
|
||||
|
||||
78
src/SASjs.ts
78
src/SASjs.ts
@@ -113,16 +113,16 @@ export default class SASjs {
|
||||
* @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 autoExecLines - the lines of code to execute during session initialization.
|
||||
* @param authorizedUsers - an optional list of authorized user IDs.
|
||||
* @param accessToken - an access token for an authorized user.
|
||||
* @param authorizedUsers - an optional list of authorized user IDs.
|
||||
*/
|
||||
public async createContext(
|
||||
contextName: string,
|
||||
launchContextName: string,
|
||||
sharedAccountId: string,
|
||||
autoExecLines: string[],
|
||||
authorizedUsers: string[],
|
||||
accessToken: string
|
||||
accessToken: string,
|
||||
authorizedUsers?: string[]
|
||||
) {
|
||||
this.isMethodSupported('createContext', ServerType.SASViya)
|
||||
|
||||
@@ -131,8 +131,8 @@ export default class SASjs {
|
||||
launchContextName,
|
||||
sharedAccountId,
|
||||
autoExecLines,
|
||||
authorizedUsers,
|
||||
accessToken
|
||||
accessToken,
|
||||
authorizedUsers
|
||||
)
|
||||
}
|
||||
|
||||
@@ -167,6 +167,38 @@ export default class SASjs {
|
||||
return await this.sasViyaApiClient!.deleteContext(contextName, accessToken)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON representation of a compute context.
|
||||
* @example: { "createdBy": "admin", "links": [...], "id": "ID", "version": 2, "name": "context1" }
|
||||
* @param contextName - the name of the context to return.
|
||||
* @param accessToken - an access token for an authorized user.
|
||||
*/
|
||||
public async getComputeContextByName(
|
||||
contextName: string,
|
||||
accessToken?: string
|
||||
) {
|
||||
this.isMethodSupported('getComputeContextByName', ServerType.SASViya)
|
||||
|
||||
return await this.sasViyaApiClient!.getComputeContextByName(
|
||||
contextName,
|
||||
accessToken
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON representation of a compute context.
|
||||
* @param contextId - an id of the context to return.
|
||||
* @param accessToken - an access token for an authorized user.
|
||||
*/
|
||||
public async getComputeContextById(contextId: string, accessToken?: string) {
|
||||
this.isMethodSupported('getComputeContextById', ServerType.SASViya)
|
||||
|
||||
return await this.sasViyaApiClient!.getComputeContextById(
|
||||
contextId,
|
||||
accessToken
|
||||
)
|
||||
}
|
||||
|
||||
public async createSession(contextName: string, accessToken: string) {
|
||||
this.isMethodSupported('createSession', ServerType.SASViya)
|
||||
|
||||
@@ -211,8 +243,6 @@ export default class SASjs {
|
||||
sasApiClient?: SASViyaApiClient,
|
||||
isForced?: boolean
|
||||
) {
|
||||
this.isMethodSupported('createFolder', ServerType.SASViya)
|
||||
|
||||
if (sasApiClient)
|
||||
return await sasApiClient.createFolder(
|
||||
folderName,
|
||||
@@ -229,6 +259,40 @@ export default class SASjs {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param folderPath - the full path (eg `/Public/example/deleteThis`) of the folder to be deleted.
|
||||
* @param accessToken - an access token for authorizing the request.
|
||||
*/
|
||||
public async deleteFolder(folderPath: string, accessToken: string) {
|
||||
this.isMethodSupported('deleteFolder', ServerType.SASViya)
|
||||
|
||||
return await this.sasViyaApiClient?.deleteFolder(folderPath, accessToken)
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves folder to a new location. The folder may be renamed at the same time.
|
||||
* @param sourceFolder - 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.
|
||||
* @param targetParentFolder - 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 path will save one extra request.
|
||||
* @param targetFolderName - 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.
|
||||
* @param accessToken - an access token for authorizing the request.
|
||||
*/
|
||||
public async moveFolder(
|
||||
sourceFolder: string,
|
||||
targetParentFolder: string,
|
||||
targetFolderName: string,
|
||||
accessToken: string
|
||||
) {
|
||||
this.isMethodSupported('moveFolder', ServerType.SASViya)
|
||||
|
||||
return await this.sasViyaApiClient?.moveFolder(
|
||||
sourceFolder,
|
||||
targetParentFolder,
|
||||
targetFolderName,
|
||||
accessToken
|
||||
)
|
||||
}
|
||||
|
||||
public async createJobDefinition(
|
||||
jobName: string,
|
||||
code: string,
|
||||
|
||||
@@ -14,4 +14,26 @@ export interface EditContextInput {
|
||||
attributes?: any
|
||||
authorizedUsers?: string[]
|
||||
authorizeAllAuthenticatedUsers?: boolean
|
||||
id?: string
|
||||
}
|
||||
|
||||
export interface ContextAllAttributes {
|
||||
attributes: {
|
||||
reuseServerProcesses: boolean
|
||||
runServerAs: string
|
||||
}
|
||||
modifiedTimeStamp: string
|
||||
createdBy: string
|
||||
creationTimeStamp: string
|
||||
launchType: string
|
||||
environment: {
|
||||
autoExecLines: [string]
|
||||
}
|
||||
launchContext: {
|
||||
contextName: string
|
||||
}
|
||||
modifiedBy: string
|
||||
id: string
|
||||
version: number
|
||||
name: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user