proxmox/plugins/module_utils/proxmox_datacenter_group.py

20 lines
625 B
Python

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']
))