1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-08 04:50:06 +00:00

feat(create-context): add list of authorized users

This commit is contained in:
Krishna Acondy
2020-09-06 21:32:48 +01:00
parent fc1d54d105
commit 26c8946fd5
2 changed files with 24 additions and 14 deletions

View File

@@ -201,6 +201,7 @@ export class SASViyaApiClient {
launchContextName: string,
sharedAccountId: string,
autoExecLines: string,
authorizedUsers: string[],
accessToken?: string
) {
if (!contextName) {
@@ -223,23 +224,30 @@ export class SASViyaApiClient {
headers.Authorization = `Bearer ${accessToken}`
}
const requestBody: any = {
name: contextName,
environment: {
autoExecLines: autoExecLines || ''
},
launchContext: {
contextName: launchContextName
},
attributes: {
reuseServerProcesses: true,
runServerAs: sharedAccountId
}
}
if (authorizedUsers && authorizedUsers.length) {
requestBody['authorizedUsers'] = authorizedUsers
} else {
requestBody['authorizeAllAuthenticatedUsers'] = true
}
const createContextRequest: RequestInit = {
method: 'POST',
headers,
body: JSON.stringify({
name: contextName,
environment: {
autoExecLines: autoExecLines || ''
},
launchContext: {
contextName: launchContextName
},
authorizeAllAuthenticatedUsers: true,
attributes: {
reuseServerProcesses: true,
runServerAs: sharedAccountId
}
})
body: JSON.stringify(requestBody)
}
const { result: context } = await this.request<Context>(