opsi-api / Exports / implements/client / Client

# Class: Client

implements/client.Client

# Implemented by

# Table of contents

# Constructors

# Methods

# Constructors

# constructor

new Client()

# Methods

# callActionForProductOnClient

callActionForProductOnClient(clientId, productId, action): Promise<IfcResult>

set an action request for the given product and the given client.

# Parameters

Name Type
clientId string
productId string
action string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:574 (opens new window)


# createClient

createClient(clientName, domain, description?, notes?, ipAddress?, hardwareAddress?): Promise<IfcResult>

create client.

example

//returns client id name in data
const { success, data, message } = await api.createClient('client01', 'opsi.lan', 'Description', 'Client notes', '192.168.0.1', 'xx:xx:xx:xx:xx:01')
console.log(data) // returns client01.opsi.lan or an error object on fail
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message

# Parameters

Name Type Default value Description
clientName string undefined Client Name
domain string undefined Client domain
description string '' description of the client
notes string '' Notes for this client
ipAddress string '' Client IP Address
hardwareAddress string '' physical address of the client

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:66 (opens new window)


# deleteClient

deleteClient(clientId): Promise<IfcResult>

delete one client by id.

example

//returns boolean only on super bad data it will return an error message
const { success, data, message } = await api.delete(clientId)
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // data returns null on success or an error object on fail

# Parameters

Name Type Description
clientId string Client ID

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:398 (opens new window)


# fireEventForClient

fireEventForClient(clientId, event): Promise<IfcResult>

fire event for clients for example on_demand

example

//returns boolean only on super bad data it will return an error message
const { success, data, message } = await api.fireEventForClient(clientId, 'on_demand')
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // data returns null on success or an error object on fail

# Parameters

Name Type
clientId string
event string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:605 (opens new window)


# getAllClients

getAllClients(): Promise<IfcResult>

Get all clients.

example

//returns array of all clients
const { success, data, message } = await api.getAllClients()
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // returns array of client objects or an error object on fail
[ { ident: 'client01.opsi.lan',
    description: 'Description',
    created: '2019-02-18 18:50:33',
    inventoryNumber: '',
    ipAddress: null,
    notes: '',
    oneTimePassword: null,
    lastSeen: '2019-02-18 18:50:33',
    hardwareAddress: null,
    opsiHostKey: '8b3ffde7170a25d48104141786ad9ba2',
    type: 'OpsiClient',
    id: 'client01.opsi.lan' } ]

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:32 (opens new window)


# getClientDetails

getClientDetails(clientId): Promise<IfcResult>

get full client details

example

const { success, data, message } = await api.getClientDetails('client01.opsi.lan')
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // data returns a huge object with relevant client data
// object structure
{
  groups: [],
  hardware: {},
  info: {},
  products: {}
};

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:329 (opens new window)


# getClientGroups

getClientGroups(clientId): Promise<IfcResult>

get all groups for one client. if client not exists it will return also true and an empty array

example

const { success, data, message } = await api.getClientGroups('client01.opsi.lan')
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // data returns a array of groups or an empty array

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:181 (opens new window)


# getClientHardware

getClientHardware(clientId): Promise<IfcResult>

if hwaudit is successfully ran on this client you will get a huge object of hardware information

example

const { success, data, message } = await api.getClientHardware('client01.opsi.lan')
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // data returns a object of hardware information or an empty object

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:216 (opens new window)


# getClientInfo

getClientInfo(clientId): Promise<IfcResult>

get client info

example

//returns object with client info
const { success, data, message } = await api.getClientInfo('client01.opsi.lan',)
console.log(data) // returns
{ ident: 'client01.opsi.lan',
 description: 'Description',
 created: '2019-02-19 18:11:10',
  inventoryNumber: '',
  ipAddress: null,
  notes: '',
  oneTimePassword: null,
  lastSeen: '2019-02-19 18:11:10',
  hardwareAddress: null,
  opsiHostKey: 'c748d0b0d2015dfda0306dc0a862a612',
  type: 'OpsiClient',
  id: 'client01.opsi.lan' }
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message

# Parameters

Name Type Description
clientId string Client ID Name

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:144 (opens new window)


# getClientLogs

getClientLogs(clientId, logType, length?): Promise<IfcResult>

get logs for client. some possible log data instlog (opsi-winst), clientconnect (opsiclientd), userlogin, bootimage and opsiconfd

# Parameters

Name Type Default value Description
clientId string undefined
logType string undefined
length number 'instlog' number of characters to show

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:469 (opens new window)


# getClientObjectConfig

getClientObjectConfig(clientId, configId): Promise<IfcResult>

get client config object

# Parameters

Name Type
clientId string
configId string

# Returns

Promise<IfcResult>

# Defined in

implements/client.ts:698 (opens new window)


# getClientObjectConfigs

getClientObjectConfigs(clientId): Promise<IfcResult>

get client config objects

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

# Defined in

implements/client.ts:680 (opens new window)


# getClientProducts

getClientProducts(clientId): Promise<IfcResult>

get all products on client

example

const { success, data, message } = await api.getClientProducts('client01.opsi.lan')
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // data returns a array of product information or an empty array

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:265 (opens new window)


# getClientProductsInstallationStatus

getClientProductsInstallationStatus(clientId): Promise<IfcResult>

get all installed and not installed opsi product for client

example

const { success, data, message } = await api.getClientProductsInstallationStatus('client01.opsi.lan')
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // data returns a array of product information or an empty array

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:298 (opens new window)


# getClientSoftware

getClientSoftware(clientId): Promise<IfcResult>

if swaudit is successfully ran on this client you will get a huge array of software information.

example

const { success, data, message } = await api.getClientSoftware('client01.opsi.lan')
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // data returns a array of software information or an empty array

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:241 (opens new window)


# getInstallableProductIds

getInstallableProductIds(clientId): Promise<IfcResult>

get all installable software packages for one client

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:450 (opens new window)


# getLoggedInUser

getLoggedInUser(clientId): Promise<IfcResult>

get logged in user data

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:432 (opens new window)


# getUptimeClient

getUptimeClient(clientId): Promise<IfcResult>

get the update in seconds from client

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:414 (opens new window)


# isClientOn

isClientOn(clientId): Promise<IfcResult>

is client on or off

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:621 (opens new window)


# rebootClient

rebootClient(clientId): Promise<IfcResult>

triggers a reboot command on the given clientId

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:506 (opens new window)


# removeClientConfigObject

removeClientConfigObject(clientId, configId): Promise<IfcResult>

remove a config value for a client

# Parameters

Name Type
clientId string
configId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:663 (opens new window)


# renameClient

renameClient(name, newname): Promise<IfcResult>

rename a client

example

//returns boolean only on super bad data it will return an error message
const { success, data, message } = await api.renameClient('client01.opsi.lan', 'client01-renamed.opsi.lan')
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // data returns also true or an error object on fail

# Parameters

Name Type Description
name string old id of the client
newname string new id

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:372 (opens new window)


# sendPopupMessageToClient

sendPopupMessageToClient(clientId, message): Promise<IfcResult>

sent a popup message to the client that appears instantly on the client desktop.

# Parameters

Name Type
clientId string
message string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:556 (opens new window)


# setClientConfigObject

setClientConfigObject(clientId, configId, value): Promise<IfcResult>

set a config value for a client

# Parameters

Name Type
clientId string
configId string
value string | number | boolean

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:640 (opens new window)


# setUefiBoot

setUefiBoot(clientId): Promise<IfcResult>

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

# Defined in

implements/client.ts:733 (opens new window)


# shutdownClient

shutdownClient(clientId): Promise<IfcResult>

triggers a shutdown command on the given clientId

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:522 (opens new window)


# startClient

startClient(clientId): Promise<IfcResult>

triggers a wake-on-lan command from the opsi server to the given clientId. Wake on Lan needs to be activated and the client.

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:539 (opens new window)


# uefiBootEnabled

uefiBootEnabled(clientId): Promise<IfcResult>

shows if uefi is enabled or disabled

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

boolean or error

# Defined in

implements/client.ts:715 (opens new window)


# unsetUefiBoot

unsetUefiBoot(clientId): Promise<IfcResult>

# Parameters

Name Type
clientId string

# Returns

Promise<IfcResult>

# Defined in

implements/client.ts:737 (opens new window)


# updateClient

updateClient(clientObject): Promise<IfcResult>

update client

example

//returns boolean only on super bad data it will return an error message
const { success, data, message } = await api.updateClient(
{ident: 'client01.opsi.lan', note: 'add update note'}
)
console.log(success) // if all data are ok then this should return true else false
console.log(message) // message is empty if success is true. if success is false there is a error message
console.log(data) // data returns also true or an error object on fail

# Parameters

Name Type Description
clientObject IfcHost group object with ident key

# Returns

Promise<IfcResult>

Object with result data

# Defined in

implements/client.ts:105 (opens new window)