opsi-api / Exports / api / OPSIApi
# Class: OPSIApi
api.OPSIApi
Class OPSIApi
# Implements
# Table of contents
# Constructors
# Properties
- addClientToGroup
- apiURL
- callActionForProductOnClient
- createClient
- createHostGroup
- deleteClient
- deleteGroup
- fireEventForClient
- getAllActionsForProduct
- getAllClients
- getAllHostGroups
- getAllHostGroupsWithClients
- getAllProducts
- getClientDetails
- getClientGroups
- getClientHardware
- getClientInfo
- getClientLogs
- getClientObjectConfig
- getClientObjectConfigs
- getClientProducts
- getClientProductsInstallationStatus
- getClientSoftware
- getClientsWithOutdatedVersion
- getGroupClients
- getHostGroupInfo
- getInstallableProductIds
- getLoggedInUser
- getProductInfo
- getUptimeClient
- groupNameExists
- id
- isClientOn
- password
- rebootClient
- removeClientConfigObject
- removeClientFromGroup
- renameClient
- renameGroup
- res
- sendPopupMessageToClient
- setClientConfigObject
- setUefiBoot
- shutdownClient
- startClient
- uefiBootEnabled
- unsetUefiBoot
- updateClient
- updateHostGroup
- updateOutdatedClients
- username
# Methods
- getOpsiServerInfo
- getOpsiVersion
- getServerIDs
- isAuthenticated
- isUserAdmin
- reduceReturnClientObject
- resetResult
- returnOneResult
- sendRequest
# Constructors
# constructor
• new OPSIApi(apiURL
, username
, password
, id?
)
Create/Initiate OPSIApi.
# Parameters
Name | Type | Default value | Description |
---|---|---|---|
apiURL | string | undefined | OPSI Api URL String Example: Https://opsiserver:4447. |
username | string | undefined | OPSI user with access rights. |
password | string | undefined | Password of the api user. |
id | number | 1 | OPSI Api Server ID. Default is 1 |
# Defined in
# Properties
# addClientToGroup
• addClientToGroup: (clientId
: string
, groupId
: string
) => Promise
<IfcResult
> = Group.prototype.addClientToGroup
# Type declaration
▸ (clientId
, groupId
): Promise
<IfcResult
>
add client to group
example
//returns boolean only on super bad data it will return an error message
const { success, data, message } = await api.addClientToGroup('grouptestclient.opsi.lan', 'group01')
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 true, false or an error object on fail
# Parameters
Name | Type | Description |
---|---|---|
clientId | string | Client ID |
groupId | string | Group ID |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.addClientToGroup
# Defined in
# apiURL
• apiURL: string
# Defined in
# callActionForProductOnClient
• callActionForProductOnClient: (clientId
: string
, productId
: string
, action
: string
) => Promise
<IfcResult
> = Client.prototype.callActionForProductOnClient
# Type declaration
▸ (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
# Implementation of
Client.callActionForProductOnClient
# Defined in
# createClient
• createClient: (clientName
: string
, domain
: string
, description
: string
, notes
: string
, ipAddress
: string
, hardwareAddress
: string
) => Promise
<IfcResult
> = Client.prototype.createClient
# Type declaration
▸ (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
# Implementation of
Client.createClient
# Defined in
# createHostGroup
• createHostGroup: (groupName
: string
, members
: string
, description
: string
, parentGroupId
: string
) => Promise
<IfcResult
> = Group.prototype.createHostGroup
# Type declaration
▸ (groupName
, members
, description?
, parentGroupId?
): Promise
<IfcResult
>
create group
example
//returns boolean only on super bad data it will return an error message
const { success, data, message } = await api.createHostGroup(
'group01',
'',
'Group description',
'')
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 | Default value | Description |
---|---|---|---|
groupName | string | undefined | Group ID Name |
members | string | undefined | Members Object? String? Array? |
description | string | '' | Group description string |
parentGroupId | string | '' | Parent Group ID Name |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.createHostGroup
# Defined in
# deleteClient
• deleteClient: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.deleteClient
# Type declaration
▸ (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
# Implementation of
Client.deleteClient
# Defined in
# deleteGroup
• deleteGroup: (groupId
: string
) => Promise
<IfcResult
> = Group.prototype.deleteGroup
# Type declaration
▸ (groupId
): Promise
<IfcResult
>
delete group if group id string is an empty string all groups would be deleted WARNING!!!
example
//returns boolean only on super bad data it will return an error message
const { success, data, message } = await api.deleteGroup('group01')
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 also boolean or an error object on fail
# Parameters
Name | Type | Description |
---|---|---|
groupId | string | Group ID |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.deleteGroup
# Defined in
# fireEventForClient
• fireEventForClient: (clientId
: string
, event
: string
) => Promise
<IfcResult
> = Client.prototype.fireEventForClient
# Type declaration
▸ (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
# Implementation of
Client.fireEventForClient
# Defined in
# getAllActionsForProduct
• getAllActionsForProduct: (productid
: string
, serverid
: number
) => Promise
<IfcResult
> = Product.prototype.getAllActionsForProduct
# Type declaration
▸ (productid
, serverid
): Promise
<IfcResult
>
Get all actions for one product.
example
const server = await api.getServerIDs();
const { success, data, message } = await api.getAllActionsForProduct('swaudit', server.data[0]);
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) // array of product actions
api.serverIDs() api.actionsForProduct('', servers[0])
# Parameters
Name | Type | Description |
---|---|---|
productid | string | Any id string. |
serverid | number | Serverid string that gets from serverIDs. |
# Returns
Promise
<IfcResult
>
Data.
# Implementation of
Product.getAllActionsForProduct
# Defined in
# getAllClients
• getAllClients: () => Promise
<IfcResult
> = Client.prototype.getAllClients
# Type declaration
▸ (): 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
# Implementation of
Client.getAllClients
# Defined in
# getAllHostGroups
• getAllHostGroups: () => Promise
<IfcResult
> = Group.prototype.getAllHostGroups
# Type declaration
▸ (): Promise
<IfcResult
>
Get all groups.
example
//returns an array of opsi groups
const { success, data, message } = await api.getAllGroups()
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 group infos or an error object on fail
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.getAllHostGroups
# Defined in
# getAllHostGroupsWithClients
• getAllHostGroupsWithClients: () => Promise
<IfcResult
> = Group.prototype.getAllHostGroupsWithClients
# Type declaration
▸ (): Promise
<IfcResult
>
Get all groups with clients.
example
//returns an array of opsi groups
const { success, data, message } = await api.getAllHostGroupsWithClients()
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 group infos or an error object on fail
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.getAllHostGroupsWithClients
# Defined in
# getAllProducts
• getAllProducts: () => Promise
<IfcResult
> = Product.prototype.getAllProducts
# Type declaration
▸ (): Promise
<IfcResult
>
Get all installed products from opsi depot.
example
const { success, data, message } = await api.getAllProducts()
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) // array of opsi products
# Returns
Promise
<IfcResult
>
Data.
# Implementation of
Product.getAllProducts
# Defined in
# getClientDetails
• getClientDetails: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getClientDetails
# Type declaration
▸ (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
# Implementation of
Client.getClientDetails
# Defined in
# getClientGroups
• getClientGroups: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getClientGroups
# Type declaration
▸ (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
# Implementation of
Client.getClientGroups
# Defined in
# getClientHardware
• getClientHardware: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getClientHardware
# Type declaration
▸ (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
# Implementation of
Client.getClientHardware
# Defined in
# getClientInfo
• getClientInfo: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getClientInfo
# Type declaration
▸ (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
# Implementation of
Client.getClientInfo
# Defined in
# getClientLogs
• getClientLogs: (clientId
: string
, logType
: string
, length
: number
) => Promise
<IfcResult
> = Client.prototype.getClientLogs
# Type declaration
▸ (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
# Implementation of
Client.getClientLogs
# Defined in
# getClientObjectConfig
• getClientObjectConfig: (clientId
: string
, configId
: string
) => Promise
<IfcResult
> = Client.prototype.getClientObjectConfig
# Type declaration
▸ (clientId
, configId
): Promise
<IfcResult
>
get client config object
# Parameters
Name | Type |
---|---|
clientId | string |
configId | string |
# Returns
Promise
<IfcResult
>
# Implementation of
Client.getClientObjectConfig
# Defined in
# getClientObjectConfigs
• getClientObjectConfigs: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getClientObjectConfigs
# Type declaration
▸ (clientId
): Promise
<IfcResult
>
get client config objects
# Parameters
Name | Type |
---|---|
clientId | string |
# Returns
Promise
<IfcResult
>
# Implementation of
Client.getClientObjectConfigs
# Defined in
# getClientProducts
• getClientProducts: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getClientProducts
# Type declaration
▸ (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
# Implementation of
Client.getClientProducts
# Defined in
# getClientProductsInstallationStatus
• getClientProductsInstallationStatus: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getClientProductsInstallationStatus
# Type declaration
▸ (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
# Implementation of
Client.getClientProductsInstallationStatus
# Defined in
# getClientSoftware
• getClientSoftware: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getClientSoftware
# Type declaration
▸ (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
# Implementation of
Client.getClientSoftware
# Defined in
# getClientsWithOutdatedVersion
• getClientsWithOutdatedVersion: (productid
: string
) => Promise
<IfcResult
> = Product.prototype.getClientsWithOutdatedVersion
# Type declaration
▸ (productid
): Promise
<IfcResult
>
Get all clients with outdated software version for one product.
example
const { success, data, message } = await api.getClientsWithOutdatedVersion('swaudit');
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) // array of client ids
# Parameters
Name | Type | Description |
---|---|---|
productid | string | Any id string. |
# Returns
Promise
<IfcResult
>
Data.
# Implementation of
Product.getClientsWithOutdatedVersion
# Defined in
# getGroupClients
• getGroupClients: (groupId
: string
) => Promise
<IfcResult
> = Group.prototype.getGroupClients
# Type declaration
▸ (groupId
): Promise
<IfcResult
>
get clients from group
example
//return array of clients
const { success, data, message } = await api.getGroupClients('group01')
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 ids in group or an error object on fail
[ { groupType: 'HostGroup',
ident: 'HostGroup;group01;grouptestclient.opsi.lan',
type: 'ObjectToGroup',
groupId: 'group01',
objectId: 'grouptestclient.opsi.lan' } ]
# Parameters
Name | Type | Description |
---|---|---|
groupId | string | Group ID |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.getGroupClients
# Defined in
# getHostGroupInfo
• getHostGroupInfo: (groupName
: string
) => Promise
<IfcResult
> = Group.prototype.getHostGroupInfo
# Type declaration
▸ (groupName
): Promise
<IfcResult
>
get group info
example
//returns object with group info
const { success, data, message } = await api.getHostGroupInfo('group01')
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)
{ ident: 'group01',
description: 'Group description',
notes: '',
parentGroupId: null,
type: 'HostGroup',
id: 'group01' }
# Parameters
Name | Type | Description |
---|---|---|
groupName | string | Group ID Name |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.getHostGroupInfo
# Defined in
# getInstallableProductIds
• getInstallableProductIds: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getInstallableProductIds
# Type declaration
▸ (clientId
): Promise
<IfcResult
>
get all installable software packages for one client
# Parameters
Name | Type |
---|---|
clientId | string |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Client.getInstallableProductIds
# Defined in
# getLoggedInUser
• getLoggedInUser: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getLoggedInUser
# Type declaration
▸ (clientId
): Promise
<IfcResult
>
get logged in user data
# Parameters
Name | Type |
---|---|
clientId | string |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Client.getLoggedInUser
# Defined in
# getProductInfo
• getProductInfo: (productId
: any
) => Promise
<IfcResult
> = Product.prototype.getProductInfo
# Type declaration
▸ (productId
): Promise
<IfcResult
>
get detailed Product infos
example
const { success, data, message } = await api.getProductInfo('swaudit')
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) // object of detailed product information
# Parameters
Name | Type |
---|---|
productId | any |
# Returns
Promise
<IfcResult
>
# Implementation of
Product.getProductInfo
# Defined in
# getUptimeClient
• getUptimeClient: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.getUptimeClient
# Type declaration
▸ (clientId
): Promise
<IfcResult
>
get the update in seconds from client
# Parameters
Name | Type |
---|---|
clientId | string |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Client.getUptimeClient
# Defined in
# groupNameExists
• groupNameExists: (groupName
: string
) => Promise
<IfcResult
> = Group.prototype.groupNameExists
# Type declaration
▸ (groupName
): Promise
<IfcResult
>
group name exists
example
//returns boolean
const { success, data, message } = await api.groupNameExists('group01')
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 true, false or an error object on fail
# Parameters
Name | Type | Description |
---|---|---|
groupName | string | Group ID Name |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.groupNameExists
# Defined in
# id
• id: number
# Defined in
# isClientOn
• isClientOn: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.isClientOn
# Type declaration
▸ (clientId
): Promise
<IfcResult
>
is client on or off
# Parameters
Name | Type |
---|---|
clientId | string |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Client.isClientOn
# Defined in
# password
• password: string
# Defined in
# rebootClient
• rebootClient: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.rebootClient
# Type declaration
▸ (clientId
): Promise
<IfcResult
>
triggers a reboot command on the given clientId
# Parameters
Name | Type |
---|---|
clientId | string |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Client.rebootClient
# Defined in
# removeClientConfigObject
• removeClientConfigObject: (clientId
: string
, configId
: string
) => Promise
<IfcResult
> = Client.prototype.removeClientConfigObject
# Type declaration
▸ (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
# Implementation of
Client.removeClientConfigObject
# Defined in
# removeClientFromGroup
• removeClientFromGroup: (clientId
: string
, groupId
: string
) => Promise
<IfcResult
> = Group.prototype.removeClientFromGroup
# Type declaration
▸ (clientId
, groupId
): Promise
<IfcResult
>
remove client from group
example
//returns boolean only on super bad data it will return an error message
const { success, data, message } = await api.removeClientFromGroup('grouptestclient.opsi.lan', 'group01')
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 also boolean or an error object on fail
# Parameters
Name | Type | Description |
---|---|---|
clientId | string | Client ID |
groupId | string | Group ID |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.removeClientFromGroup
# Defined in
# renameClient
• renameClient: (name
: string
, newname
: string
) => Promise
<IfcResult
> = Client.prototype.renameClient
# Type declaration
▸ (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
# Implementation of
Client.renameClient
# Defined in
# renameGroup
• renameGroup: (name
: string
, newname
: string
) => Promise
<IfcResult
> = Group.prototype.renameGroup
# Type declaration
▸ (name
, newname
): Promise
<IfcResult
>
example
//returns boolean only on super bad data it will return an error message
const { success, data, message } = await api.renameGroup('group01', 'group01-renamed')
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 also boolean or an error object on fail
# Parameters
Name | Type | Description |
---|---|---|
name | string | old id of the group |
newname | string | id |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.renameGroup
# Defined in
# res
• res: IfcResult
# Defined in
# sendPopupMessageToClient
• sendPopupMessageToClient: (clientId
: string
, message
: string
) => Promise
<IfcResult
> = Client.prototype.sendPopupMessageToClient
# Type declaration
▸ (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
# Implementation of
Client.sendPopupMessageToClient
# Defined in
# setClientConfigObject
• setClientConfigObject: (clientId
: string
, configId
: string
, value
: string
| number
| boolean
) => Promise
<IfcResult
> = Client.prototype.setClientConfigObject
# Type declaration
▸ (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
# Implementation of
Client.setClientConfigObject
# Defined in
# setUefiBoot
• setUefiBoot: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.setUefiBoot
# Type declaration
▸ (clientId
): Promise
<IfcResult
>
# Parameters
Name | Type |
---|---|
clientId | string |
# Returns
Promise
<IfcResult
>
# Implementation of
Client.setUefiBoot
# Defined in
# shutdownClient
• shutdownClient: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.shutdownClient
# Type declaration
▸ (clientId
): Promise
<IfcResult
>
triggers a shutdown command on the given clientId
# Parameters
Name | Type |
---|---|
clientId | string |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Client.shutdownClient
# Defined in
# startClient
• startClient: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.startClient
# Type declaration
▸ (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
# Implementation of
Client.startClient
# Defined in
# uefiBootEnabled
• uefiBootEnabled: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.uefiBootEnabled
# Type declaration
▸ (clientId
): Promise
<IfcResult
>
shows if uefi is enabled or disabled
# Parameters
Name | Type |
---|---|
clientId | string |
# Returns
Promise
<IfcResult
>
boolean or error
# Implementation of
Client.uefiBootEnabled
# Defined in
# unsetUefiBoot
• unsetUefiBoot: (clientId
: string
) => Promise
<IfcResult
> = Client.prototype.unsetUefiBoot
# Type declaration
▸ (clientId
): Promise
<IfcResult
>
# Parameters
Name | Type |
---|---|
clientId | string |
# Returns
Promise
<IfcResult
>
# Implementation of
Client.unsetUefiBoot
# Defined in
# updateClient
• updateClient: (clientObject
: IfcHost
) => Promise
<IfcResult
> = Client.prototype.updateClient
# Type declaration
▸ (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
# Implementation of
Client.updateClient
# Defined in
# updateHostGroup
• updateHostGroup: (groupObject
: IfcGroup
) => Promise
<IfcResult
> = Group.prototype.updateHostGroup
# Type declaration
▸ (groupObject
): Promise
<IfcResult
>
update group
example
//returns boolean only on super bad data it will return an error message
const { success, data, message } = await api.updateHostGroup(
{ident: 'group01', 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 |
---|---|---|
groupObject | IfcGroup | group object with ident key |
# Returns
Promise
<IfcResult
>
Object with result data
# Implementation of
Group.updateHostGroup
# Defined in
# updateOutdatedClients
• updateOutdatedClients: (productid
: string
) => Promise
<IfcResult
> = Product.prototype.updateOutdatedClients
# Type declaration
▸ (productid
): Promise
<IfcResult
>
Update clients with outdated software.
example
const { success, data, message } = await api.updateOutdatedClients('swaudit');
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) // array of client ids
# Parameters
Name | Type | Description |
---|---|---|
productid | string | Any id string. |
# Returns
Promise
<IfcResult
>
Data.
# Implementation of
Product.updateOutdatedClients
# Defined in
# username
• username: string
# Defined in
# Methods
# getOpsiServerInfo
▸ getOpsiServerInfo(): Promise
<IfcResult
>
Get server infos.
example
// returns array with objects of server data
api.getOpsiServerInfo()
# Returns
Promise
<IfcResult
>
Data.
# Defined in
# getOpsiVersion
▸ getOpsiVersion(): Promise
<IfcResult
>
Get opsi version or false.
example
// returns a string of the opsi version or false
api.getOpsiVersion()
# Returns
Promise
<IfcResult
>
Data.
# Defined in
# getServerIDs
▸ getServerIDs(): Promise
<IfcResult
>
Get all server ids.
example
// returns array of server ids
api.serverIDs()
# Returns
Promise
<IfcResult
>
Data.
# Defined in
# isAuthenticated
▸ isAuthenticated(): Promise
<IfcResult
>
Is api user authenticated.
example
// returns boolean if user is logged in or not
api.isAuthenticated()
# Returns
Promise
<IfcResult
>
Data.
# Defined in
# isUserAdmin
▸ isUserAdmin(): Promise
<IfcResult
>
Is api user admin.
example
// returns if user has admin rights
api.isUserAdmin()
# Returns
Promise
<IfcResult
>
Data.
# Defined in
# reduceReturnClientObject
▸ reduceReturnClientObject(result
, clientId
): IfcResult
# Parameters
Name | Type |
---|---|
result | any |
clientId | any |
# Returns
# Defined in
# resetResult
▸ Protected
resetResult(): Object
# Returns
Object
Name | Type |
---|---|
data | boolean |
message | string |
success | false |
# Defined in
# returnOneResult
▸ returnOneResult(result
, notFoundMessage
): IfcResult
manipulate the result to an error or to one return object
# Parameters
Name | Type | Description |
---|---|---|
result | any | IfcResult to manipulate |
notFoundMessage | any | message string that returns if result is empty |
# Returns
- nice IfcResult with useful data
# Defined in
# sendRequest
▸ Private
sendRequest(method
, params
, id
): Promise
<IfcResult
>
Generate api call actions.
# Parameters
Name | Type | Description |
---|---|---|
method | string | Api function name to call. |
params | any [] | Array of method parameters. |
id | number | Id number. |
# Returns
Promise
<IfcResult
>