feat(group): add module for retrieving groups present in proxmox node
This commit is contained in:
19
plugins/module_utils/proxmox_datacenter_group.py
Normal file
19
plugins/module_utils/proxmox_datacenter_group.py
Normal file
@ -0,0 +1,19 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import List, Tuple
|
||||
|
||||
from ansible_collections.finallycoffee.proxmox.plugins.module_utils.common import _proxmox_request, ProxmoxAuthInfo
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ProxmoxGroup:
|
||||
name: str
|
||||
members: List = field(default_factory=lambda: [])
|
||||
comment: str = None
|
||||
|
||||
|
||||
def get_groups(auth_info: ProxmoxAuthInfo) -> List['ProxmoxGroups']:
|
||||
group_answer = _proxmox_request('get', '/access/groups', auth_info).json()
|
||||
return list(map(
|
||||
lambda r: ProxmoxGroup(r['groupid'], r['users'].split(','), r.get('comment', '')),
|
||||
group_answer['data']
|
||||
))
|
Reference in New Issue
Block a user