Admin Service

This service provides a handle to admin related APIs which currently has logging related APIs.

Creation of Admin Service

To create Admin client

Typescript
sourceconst adminService: AdminService = await AdminService()

Usages of Admin Service

Type definitions for all Admin Service methods can be found here.

Fetching LogMetadata & Setting log level

For instance, we need logging configuration to be known before setting log level of a component if it is not set to desired log level.

Type definitions for getLogMetadata can be found here. Type definitions for setLogLevel can be found here.

In the given example, we want to set ERROR log level for the component if it’s not already set to ERROR.

Typescript
sourceconst prefix = new Prefix('TCS', 'filter.wheel')
const componentId = new ComponentId(prefix, 'HCD')

const logMetaData: LogMetadata = await adminService.getLogMetadata(componentId)

if (logMetaData.componentLevel !== 'ERROR') {
  const actionStatus: Done = await adminService.setLogLevel(componentId, 'ERROR')
}

Component & Container level actions

Admin actions like restarting, shutting down or making component(HCD, Assembly) or container to go online/offline are provided in Admin Service. Following examples represents admin actions provided on Admin Service.

Type definitions for restart can be found here. Type definitions for shutdown can be found here. Type definitions for goOffline can be found here. Type definitions for goOnline can be found here.

Typescript
sourceconst restartResponse: Done = await adminService.restart(componentId)

const shutdownResponse: Done = await adminService.shutdown(componentId)

const goOfflineResponse: Done = await adminService.goOffline(componentId)

const goOnlineResponse: Done = await adminService.goOnline(componentId)

Querying lifecycle states of Component & Container

Component(HCD, Assembly) lifecycle states are queried using getComponentLifecycleState API Method.

Container lifecycle state is queried using getContainerLifecycleState API Method.

Following examples shows how to make use of these API’s.

Type definitions for getContainerLifecycleState can be found here Type definitions for getComponentLifecycleState can be found here

Typescript
source// component lifecycle state
const response: Done = await adminService.goOnline(componentId)
if (response === 'Done') {
  const state: SupervisorLifecycleState = await adminService.getComponentLifecycleState(componentId)

  switch (state) {
    case 'Idle':
      break
    case 'Running':
      break
    case 'Shutdown':
      break
    default:
      console.log('unhandled state')
  }
}

// container lifecycle state
const containerPrefix = Prefix.fromString('ESW.container1')
const state: ContainerLifecycleState = await adminService.getContainerLifecycleState(containerPrefix)

switch (state) {
  case 'Idle':
    break
  case 'Running':
    break
}