<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

ANSIBLE_METADATA = {
    'metadata_version': '0.1',
    'status': ['preview'],
    'supported_by': 'lae'
}

DOCUMENTATION = '''
---
module: proxmox_acl

short_description: Manages the Access Control List in Proxmox

options:
    path:
        required: true
        aliases: [ "resource" ]
        description:
            - Location of the resource to apply access control to.
    roles:
        required: true
        type: list
        description:
            - Specifies a list of PVE roles, which contains sets of privileges,
              to allow for this access control.
    state:
        required: false
        default: "present"
        choices: [ "present", "absent" ]
        description:
            - Specifies whether this access control should exist or not.
    groups:
        required: false
        type: list
        description:
            - Specifies a list of PVE groups to apply this access control for.
    users:
        required: false
        type: list
        description:
            - Specifies a list of PVE users to apply this access control for.

author:
    - <NAME> (@lae)
'''

EXAMPLES = '''
- name: Allow Admins group Administrator access to /
  proxmox_acl:
    path: /
    roles: [ "Administrator" ]
    groups: [ "Admins" ]
- name: Allow pveapi@pve and test_users group PVEAdmin access to /pools/testpool
  proxmox_acl:
    path: /pools/testpool
    roles: [ "PVEAdmin" ]
    users:
      - pveapi@pve
    groups:
      - test_users
'''

RETURN = '''
'''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pvesh import ProxmoxShellError
import ansible.module_utils.pvesh as pvesh

class ProxmoxACL(object):
    def __init__(self, module):
        self.module = module
        self.path = module.params['path']
        self.state = module.params['state']
        self.roles = module.params['roles']
        self.groups = module.params['groups']
        self.users = module.params['users']

        try:
            self.existing_acl = pvesh.get("access/acl")
        except ProxmoxShellError as e:
            self.module.fail_json(msg=e.message, status_code=e.status_code)

        self.parse_acls()

    def parse_acls(self):<commit_msg>Always treat 'propagate' value as an integer<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

ANSIBLE_METADATA = {
    'metadata_version': '0.1',
    'status': ['preview'],
    'supported_by': 'lae'
}

DOCUMENTATION = '''
---
module: proxmox_acl

short_description: Manages the Access Control List in Proxmox

options:
    path:
        required: true
        aliases: [ "resource" ]
        description:
            - Location of the resource to apply access control to.
    roles:
        required: true
        type: list
        description:
            - Specifies a list of PVE roles, which contains sets of privileges,
              to allow for this access control.
    state:
        required: false
        default: "present"
        choices: [ "present", "absent" ]
        description:
            - Specifies whether this access control should exist or not.
    groups:
        required: false
        type: list
        description:
            - Specifies a list of PVE groups to apply this access control for.
    users:
        required: false
        type: list
        description:
            - Specifies a list of PVE users to apply this access control for.

author:
    - <NAME> (@lae)
'''

EXAMPLES = '''
- name: Allow Admins group Administrator access to /
  proxmox_acl:
    path: /
    roles: [ "Administrator" ]
    groups: [ "Admins" ]
- name: Allow pveapi@pve and test_users group PVEAdmin access to /pools/testpool
  proxmox_acl:
    path: /pools/testpool
    roles: [ "PVEAdmin" ]
    users:
      - pveapi@pve
    groups:
      - test_users
'''

RETURN = '''
'''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pvesh import ProxmoxShellError
import ansible.module_utils.pvesh as pvesh

class ProxmoxACL(object):
    def __init__(self, module):
        self.module = module
        self.path = module.params['path']
        self.state = module.params['state']
        self.roles = module.params['roles']
        self.groups = module.params['groups']
        self.users = module.params['users']

        try:
            self.existing_acl = pvesh.get("access/acl")
        except ProxmoxShellError as e:
            self.module.fail_json(msg=e.message, status_code=e.status_code)

        # PVE 5.x (unnecessarily) uses a string for this value. This ensures
        # that it's an integer for when we compare values later.
        for acl in self.existing_acl:
            acl['propagate'] = int(acl['propagate'])

        self.parse_acls()

    def parse_acls(self):
{'fraction_non_alphanumeric': 0.10047846889952153, 'fraction_numerical': 0.0014562096941959641, 'mean_word_length': 2.2886456908344734, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '623399', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1456, 'n_words': 416}