src/app/services/sas-viya.service.ts
| providedIn | root |
Properties |
Methods |
constructor(http: HttpClient, appStoreService: AppStoreService)
|
|||||||||
|
Defined in src/app/services/sas-viya.service.ts:68
|
|||||||||
|
Parameters :
|
| get |
get<T>(url: string, options?: { headers?: HttpHeaders | literal type; context?: HttpContext; observe?: body; params?: HttpParams | literal type; reportProgress?: boolean; responseType?: json; withCredentials?: boolean; transferCache?: literal type | boolean })
|
|
Defined in src/app/services/sas-viya.service.ts:197
|
Type parameters :
|
|
Parameters :
Returns :
Observable<T>
|
| getAdminGroups | ||||||||
getAdminGroups(limit: number)
|
||||||||
|
Defined in src/app/services/sas-viya.service.ts:165
|
||||||||
|
Parameters :
Returns :
Observable<ViyaApiIdentities>
|
| getAllCollections |
getAllCollections()
|
|
Defined in src/app/services/sas-viya.service.ts:96
|
|
Returns :
ViyaApis
All Viya API collections that we support |
| getByCollection | ||||||
getByCollection(apiCollection: string)
|
||||||
|
Defined in src/app/services/sas-viya.service.ts:116
|
||||||
|
We refer collection as starting point /jobs /folders etc.
Parameters :
Returns :
Observable<Collection>
|
| getByUrl | ||||||||
getByUrl(url: string)
|
||||||||
|
Defined in src/app/services/sas-viya.service.ts:105
|
||||||||
|
Used for clicking trough collections / apis
Parameters :
Returns :
Observable<Collection>
|
| getComputeContextById | ||||||
getComputeContextById(id: string)
|
||||||
|
Defined in src/app/services/sas-viya.service.ts:131
|
||||||
|
Parameters :
Returns :
Observable<ComputeContextDetails>
|
| getComputeContexts |
getComputeContexts()
|
|
Defined in src/app/services/sas-viya.service.ts:122
|
|
Returns :
Observable<ViyaComputeContexts>
|
| getCurrentUser |
getCurrentUser()
|
|
Defined in src/app/services/sas-viya.service.ts:188
|
|
Returns :
Observable<ViyaApiCurrentUser>
|
| getCurrentUserGroupMemberships | ||||||||
getCurrentUserGroupMemberships(limit: number)
|
||||||||
|
Defined in src/app/services/sas-viya.service.ts:177
|
||||||||
|
Parameters :
Returns :
Observable<ViyaApiIdentities>
The groups the current user is a member of |
| getFolderByPath | ||||||||
getFolderByPath(path: string)
|
||||||||
|
Defined in src/app/services/sas-viya.service.ts:144
|
||||||||
|
Parameters :
Returns :
Observable<ViyaApiFolder>
The folder info object |
| getFolderMembers |
getFolderMembers(folderId: string, limit: number)
|
|
Defined in src/app/services/sas-viya.service.ts:153
|
|
Returns :
Observable<ViyaApiFolderMembers>
|
| setup |
setup()
|
|
Defined in src/app/services/sas-viya.service.ts:81
|
|
This function is replacing the constructor.
The reason for this is timing issues, other services eg. sas.service, app-store.service
must be initialized before this bit of code is executed.
This function is being called by
Returns :
void
|
| Private serverUrl |
Type : string
|
Default value : ''
|
|
Defined in src/app/services/sas-viya.service.ts:68
|
| Public viyaApis |
Type : ViyaApis
|
Default value : {
Analytics_Insights: {
insights: '/insights'
},
Visualisation: {
reports: '/reports',
reportImages: '/reportImages',
reportTransforms: '/reportTransforms',
visualAnalytics: '/visualAnalytics'
},
Compute: {
jobs: '/jobDefinitions',
jobExecution: '/jobExecution',
contexts: '/compute/contexts'
},
Decision_Management: {
modelManagement: '/modelManagement',
modelRepository: '/modelRepository',
modelPublish: '/modelPublish',
microanalyticScore: '/microanalyticScore',
dataMining: '/dataMining',
businessRules: '/businessRules',
referenceData: '/referenceData',
treatmentDefinitions: '/treatmentDefinitions',
subjectContacts: '/subjectContacts',
decisionsRuntimeBuilder: '/decisionsRuntimeBuilder'
},
Core_Services: {
folders: '/folders',
files: '/files',
annotations: '/annotations',
authorization: '/authorization',
relationships: '/relationships',
SASLogon: '/SASLogon'
},
Automated_Machine_Learning: {
mlPipelineAutomation: '/mlPipelineAutomation'
},
Other: {
identities: '/identities'
}
}
|
|
Defined in src/app/services/sas-viya.service.ts:25
|
import {
HttpClient,
HttpContext,
HttpErrorResponse,
HttpHeaders,
HttpParams
} from '@angular/common/http'
import { Injectable } from '@angular/core'
import { catchError, Observable, throwError } from 'rxjs'
import { Collection } from '../viya-api-explorer/models/collection.model'
import { AppStoreService } from './app-store.service'
import { ViyaApis } from '../viya-api-explorer/models/viya-apis.models'
import { ViyaApiFolderMembers } from '../viya-api-explorer/models/viya-api-folder-content.model'
import { ViyaApiFolder } from '../viya-api-explorer/models/viya-api-folder.model'
import { ViyaApiIdentities } from '../viya-api-explorer/models/viya-api-identities.model'
import { ViyaApiCurrentUser } from '../viya-api-explorer/models/viya-api-current-user.model'
import { ViyaComputeContexts } from '../viya-api-explorer/models/viya-compute-contexts.model'
import { ComputeContextDetails } from '../viya-api-explorer/models/viya-compute-context-details.model'
@Injectable({
providedIn: 'root'
})
export class SasViyaService {
// Viya APIs
public viyaApis: ViyaApis = {
Analytics_Insights: {
insights: '/insights'
},
Visualisation: {
reports: '/reports',
reportImages: '/reportImages',
reportTransforms: '/reportTransforms',
visualAnalytics: '/visualAnalytics'
},
Compute: {
jobs: '/jobDefinitions',
jobExecution: '/jobExecution',
contexts: '/compute/contexts'
},
Decision_Management: {
modelManagement: '/modelManagement',
modelRepository: '/modelRepository',
modelPublish: '/modelPublish',
microanalyticScore: '/microanalyticScore',
dataMining: '/dataMining',
businessRules: '/businessRules',
referenceData: '/referenceData',
treatmentDefinitions: '/treatmentDefinitions',
subjectContacts: '/subjectContacts',
decisionsRuntimeBuilder: '/decisionsRuntimeBuilder'
},
Core_Services: {
folders: '/folders',
files: '/files',
annotations: '/annotations',
authorization: '/authorization',
relationships: '/relationships',
SASLogon: '/SASLogon'
},
Automated_Machine_Learning: {
mlPipelineAutomation: '/mlPipelineAutomation'
},
Other: {
identities: '/identities'
}
}
private serverUrl: string = ''
constructor(
private http: HttpClient,
private appStoreService: AppStoreService
) {}
/**
* This function is replacing the constructor.
* The reason for this is timing issues, other services eg. sas.service, app-store.service
* must be initialized before this bit of code is executed.
* This function is being called by `sas.service`
*/
setup() {
const adapterConfig = this.appStoreService.getDcAdapterSettings()
this.serverUrl = adapterConfig?.serverUrl || ''
// example collection request
// this.getByCollection('jobs').subscribe((res) => {
// console.log('res', res)
// })
}
/**
*
* @returns All Viya API collections that we support
*/
getAllCollections() {
return this.viyaApis
}
/**
* Used for clicking trough collections / apis
* @param url collection/api endpoint url
* @returns
*/
getByUrl(url: string): Observable<Collection> {
return this.get<Collection>(`${this.serverUrl}${url}`, {
withCredentials: true
})
}
/**
* We refer collection as starting point /jobs /folders etc.
* @param apiCollection
* @returns
*/
getByCollection(apiCollection: string): Observable<Collection> {
return this.get<Collection>(`${this.serverUrl}${apiCollection}`, {
withCredentials: true
})
}
getComputeContexts(): Observable<ViyaComputeContexts> {
return this.get<ViyaComputeContexts>(
`${this.serverUrl}/compute/contexts?limit=1000`,
{
withCredentials: true
}
)
}
getComputeContextById(id: string): Observable<ComputeContextDetails> {
return this.get<ComputeContextDetails>(
`${this.serverUrl}/compute/contexts/${id}`,
{
withCredentials: true
}
)
}
/**
* @param path Path to the folder
* @returns The folder info object
*/
getFolderByPath(path: string): Observable<ViyaApiFolder> {
return this.get<ViyaApiFolder>(
`${this.serverUrl}/folders/folders/@item?path=${path}`,
{
withCredentials: true
}
)
}
getFolderMembers(
folderId: string,
limit: number = 500
): Observable<ViyaApiFolderMembers> {
return this.get<ViyaApiFolderMembers>(
`${this.serverUrl}/folders/folders/${folderId}/members?limit=${limit}`,
{
withCredentials: true
}
)
}
getAdminGroups(limit: number = 5000): Observable<ViyaApiIdentities> {
return this.get<ViyaApiIdentities>(
`${this.serverUrl}/identities/groups?sortBy=name&limit=${limit}`,
{
withCredentials: true
}
)
}
/**
* @returns The groups the current user is a member of
*/
getCurrentUserGroupMemberships(
limit: number = 10000
): Observable<ViyaApiIdentities> {
return this.get<ViyaApiIdentities>(
`${this.serverUrl}/identities/users/@currentUser/memberships?limit=${limit}`,
{
withCredentials: true
}
)
}
getCurrentUser(): Observable<ViyaApiCurrentUser> {
return this.get<ViyaApiCurrentUser>(
`${this.serverUrl}/identities/users/@currentUser`,
{
withCredentials: true
}
)
}
get<T>(
url: string,
options?: {
headers?:
| HttpHeaders
| {
[header: string]: string | string[]
}
context?: HttpContext
observe?: 'body'
params?:
| HttpParams
| {
[param: string]:
| string
| number
| boolean
| ReadonlyArray<string | number | boolean>
}
reportProgress?: boolean
responseType?: 'json'
withCredentials?: boolean
transferCache?:
| {
includeHeaders?: string[]
}
| boolean
}
): Observable<T> {
return this.http.get<T>(url, options).pipe(
catchError((err: HttpErrorResponse) => {
console.log('url', url)
console.log('err.status', err.status)
if (err.status === 449 || err.status === 401) {
// Retry once if we got a 449
return this.http.get<T>(url, options)
}
// Otherwise propagate the error
return throwError(() => err)
})
)
}
}