
    Vh                     l    d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZmZmZmZ d Zedk(  r e        y	y	)
    )absolute_importdivisionprint_functionu!  
module: udm_group
author:
  - Tobias Rüetschi (@keachi)
short_description: Manage of the posix group
description:
  - This module allows to manage user groups on a univention corporate server (UCS). It uses the Python API of the UCS to
    create a new object or edit it.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: partial
options:
  state:
    required: false
    default: "present"
    choices: [present, absent]
    description:
      - Whether the group is present or not.
    type: str
  name:
    required: true
    description:
      - Name of the POSIX group.
    type: str
  description:
    required: false
    description:
      - Group description.
    type: str
  position:
    required: false
    description:
      - Define the whole LDAP position of the group, for example V(cn=g123m-1A,cn=classes,cn=schueler,cn=groups,ou=schule,dc=example,dc=com).
    type: str
    default: ''
  ou:
    required: false
    description:
      - LDAP OU, for example V(school) for LDAP OU V(ou=school,dc=example,dc=com).
    type: str
    default: ''
  subpath:
    required: false
    description:
      - Subpath inside the OU, for example V(cn=classes,cn=students,cn=groups).
    type: str
    default: "cn=groups"
a   
- name: Create a POSIX group
  community.general.udm_group:
    name: g123m-1A

# Create a POSIX group with the exact DN
# C(cn=g123m-1A,cn=classes,cn=students,cn=groups,ou=school,dc=school,dc=example,dc=com)
- name: Create a POSIX group with a DN
  community.general.udm_group:
    name: g123m-1A
    subpath: 'cn=classes,cn=students,cn=groups'
    ou: school

# or
- name: Create a POSIX group with a DN
  community.general.udm_group:
    name: g123m-1A
    position: 'cn=classes,cn=students,cn=groups,ou=school,dc=school,dc=example,dc=com'
#)AnsibleModule)umc_module_for_addumc_module_for_editldap_searchbase_dnc                      t        t        t        dd      t        d      t        dd      t        dd      t        dd      t        ddd	gd
            d      } | j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }d}d }t        t	        dj                  |      dg            }	|dk7  r|}
nG|dk7  rdj                  |      }|dk7  rdj                  |      }dj                  ||t                     }
dj                  ||
      }t        t        |	            }|dk(  rx	 |st        d|
      }nt        d|      }||d<   ||d<   |j                         }|j                         g k7  }| j                  s#|s|j                          n|j                          |d	k(  r-|r+	 t        d|      }| j                  s|j#                          d}| j%                  ||||
       y # t        $ r% | j!                  dj                  ||
             Y uw xY w# t        $ r$ | j!                  dj                  |             Y sw xY w) NTstr)requiredtype)r    )defaultr   z	cn=groupspresentabsent)r   choicesr   )namedescriptionpositionousubpathstate)argument_specsupports_check_moder   r   r   r   r   r   Fz#(&(objectClass=posixGroup)(cn={0}))cn)attrzou={0},z{0},z	{0}{1}{2}z
cn={0},{1}zgroups/groupz(Creating/editing group {0} in {1} failed)msgzRemoving group {0} failed)changedr   diff	container)r   dictparamslistr
   formatr   boollenr   r	   r!   
check_modecreatemodify	Exception	fail_jsonremove	exit_json)moduler   r   r   r   r   r   r    r!   groupsr"   group_dnexistsgrps                 o/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/udm_group.pymainr6   c   s   t "%("$&B #%y )84!#
 !F" == D--.K}}Z(H	t	BmmI&GMM'"EGD+-44T:V F 2~	8!!"%Bb=mmG,G&&wGI>	""43H#f+F		(C).(CCK!,C88:DhhjB&G$$JJLJJL V	%nh?C$$

G 	  !  	>EEdIV  	  	/66t<  	s%    A7H *I +II*I=<I=__main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Iansible_collections.community.general.plugins.module_utils.univention_umcr   r	   r
   r   r6   __name__     r5   <module>rB      sQ    A @3l* 
 4 Od zF rA   