feat(group): add module for retrieving groups present in proxmox node

This commit is contained in:
2022-08-14 17:01:40 +02:00
parent 31550df5f3
commit 551d0639cc
2 changed files with 146 additions and 0 deletions

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