opsi-api / Exports / implements/group / Group
# Class: Group
implements/group.Group
# Implemented by
# Table of contents
# Constructors
# Methods
- addClientToGroup
- createHostGroup
- deleteGroup
- getAllHostGroups
- getAllHostGroupsWithClients
- getGroupClients
- getHostGroupInfo
- groupNameExists
- removeClientFromGroup
- renameGroup
- updateHostGroup
# Constructors
# constructor
• new Group()
# Methods
# addClientToGroup
▸ addClientToGroup(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
# Defined in
implements/group.ts:225 (opens new window)
# createHostGroup
▸ createHostGroup(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
# Defined in
implements/group.ts:28 (opens new window)
# deleteGroup
▸ deleteGroup(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
# Defined in
implements/group.ts:386 (opens new window)
# getAllHostGroups
▸ getAllHostGroups(): 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
# Defined in
implements/group.ts:137 (opens new window)
# getAllHostGroupsWithClients
▸ getAllHostGroupsWithClients(): 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
# Defined in
implements/group.ts:156 (opens new window)
# getGroupClients
▸ getGroupClients(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
# Defined in
implements/group.ts:276 (opens new window)
# getHostGroupInfo
▸ getHostGroupInfo(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
# Defined in
implements/group.ts:101 (opens new window)
# groupNameExists
▸ groupNameExists(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
# Defined in
implements/group.ts:199 (opens new window)
# removeClientFromGroup
▸ removeClientFromGroup(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
# Defined in
implements/group.ts:313 (opens new window)
# renameGroup
▸ renameGroup(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
# Defined in
implements/group.ts:359 (opens new window)
# updateHostGroup
▸ updateHostGroup(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