Ë
    ÇVh¦  ã                  ó‚   — d dl mZ dZdZdZd dlmZ ddlmZ ddl	m
Z
 dd	lmZ  G d
„ de«      Zd„ Zedk(  r e«        yy)é    )Úannotationsa1  
---
module: placement_group

short_description: Create and manage placement groups on the Hetzner Cloud.


description:
    - Create, update and manage placement groups on the Hetzner Cloud.

author:
    - Adrian Huber (@Adi146)

options:
    id:
        description:
            - The ID of the Hetzner Cloud placement group to manage.
            - Only required if no placement group I(name) is given
        type: int
    name:
        description:
            - The Name of the Hetzner Cloud placement group to manage.
            - Only required if no placement group I(id) is given, or a placement group does not exist.
        type: str
    labels:
        description:
            - User-defined labels (key-value pairs)
        type: dict
    type:
        description:
            - The Type of the Hetzner Cloud placement group.
        type: str
    state:
        description:
            - State of the placement group.
        default: present
        choices: [ absent, present ]
        type: str

extends_documentation_fragment:
- hetzner.hcloud.hcloud
aÞ  
- name: Create a basic placement group
  hetzner.hcloud.placement_group:
    name: my-placement-group
    state: present
    type: spread

- name: Create a placement group with labels
  hetzner.hcloud.placement_group:
    name: my-placement-group
    type: spread
    labels:
      key: value
      mylabel: 123
    state: present

- name: Ensure the placement group is absent (remove if needed)
  hetzner.hcloud.placement_group:
    name: my-placement-group
    state: absent
a§  
hcloud_placement_group:
    description: The placement group instance
    returned: Always
    type: complex
    contains:
        id:
            description: Numeric identifier of the placement group
            returned: always
            type: int
            sample: 1937415
        name:
            description: Name of the placement group
            returned: always
            type: str
            sample: my placement group
        labels:
            description: User-defined labels (key-value pairs)
            returned: always
            type: dict
        type:
            description: Type of the placement group
            returned: always
            type: str
            sample: spread
        servers:
            description: Server IDs of the placement group
            returned: always
            type: list
            elements: int
            sample:
                - 4711
                - 4712
)ÚAnsibleModuleé   )ÚAnsibleHCloud)ÚHCloudException)ÚBoundPlacementGroupc                  ó`   ‡ — e Zd ZU dZdZded<   d„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zeˆ fd
„«       Zˆ xZS )ÚAnsibleHCloudPlacementGroupÚhcloud_placement_groupNzBoundPlacementGroup | Nonec                óì   — t        | j                  j                  «      | j                  j                  | j                  j                  | j                  j
                  | j                  j                  dœS )N)ÚidÚnameÚlabelsÚtypeÚservers)Ústrr   r   r   r   r   r   ©Úselfs    úr/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/hetzner/hcloud/plugins/modules/placement_group.pyÚ_prepare_resultz+AnsibleHCloudPlacementGroup._prepare_resulty   s\   € äd×1Ñ1×4Ñ4Ó5Ø×/Ñ/×4Ñ4Ø×1Ñ1×8Ñ8Ø×/Ñ/×4Ñ4Ø×2Ñ2×:Ñ:ñ
ð 	
ó    c                ó   — 	 | j                   j                  j                  d«      N| j                  j                  j                  | j                   j                  j                  d«      «      | _        y | j                   j                  j                  d«      N| j                  j                  j                  | j                   j                  j                  d«      «      | _        y y # t        $ r}| j                  |«       Y d }~y d }~ww xY w)Nr   r   )
ÚmoduleÚparamsÚgetÚclientÚplacement_groupsÚ	get_by_idr   Úget_by_namer   Úfail_json_hcloud)r   Ú	exceptions     r   Ú_get_placement_groupz0AnsibleHCloudPlacementGroup._get_placement_group‚   sÏ   € ð	-Ø{‰{×!Ñ!×%Ñ% dÓ+Ð7Ø.2¯k©k×.JÑ.J×.TÑ.TÐUY×U`ÑU`×UgÑUg×UkÑUkÐlpÓUqÓ.rÕ+Ø—‘×#Ñ#×'Ñ'¨Ó/Ð;Ø.2¯k©k×.JÑ.J×.VÑ.VÐW[×WbÑWb×WiÑWi×WmÑWmÐntÓWuÓ.vÕ+ð <øäò 	-Ø×!Ñ! )×,Ñ,ûð	-ús   ‚A2C) Á5A2C) Ã)	DÃ2DÄDc                ó(  — | j                   j                  dg¬«       | j                   j                  j                  d«      | j                   j                  j                  d«      | j                   j                  j                  d«      dœ}| j                   j                  s'	  | j
                  j                  j                  di |¤Ž | j                  «        | j                  «        y # t        $ r}| j                  ||¬«       Y d }~ŒBd }~ww xY w)Nr   ©Úrequired_paramsr   r   )r   r   r   )r   © )r   Úfail_on_missing_paramsr   r   Ú
check_moder   r   Úcreater   r    Ú_mark_as_changedr"   )r   r   r!   s      r   Ú_create_placement_groupz3AnsibleHCloudPlacementGroup._create_placement_group‹   sÞ   € Ø‰×*Ñ*¸F¸8Ð*ÔDà—K‘K×&Ñ&×*Ñ*¨6Ó2Ø—K‘K×&Ñ&×*Ñ*¨6Ó2Ø—k‘k×(Ñ(×,Ñ,¨XÓ6ñ
ˆð
 {‰{×%Ò%ð@Ø3—‘×,Ñ,×3Ñ3Ñ=°fÒ=ð 	×ÑÔØ×!Ñ!Õ#øô #ò @Ø×%Ñ% i¸Ð%×?Ñ?ûð@ús   Â$&C+ Ã+	DÃ4DÄDc                óf  — | j                   j                  j                  d«      }|x| j                  j                  |k7  r_| j                   j                  dg¬«       | j                   j                  s| j                  j                  |¬«       | j                  «        | j                   j                  j                  d«      }|[| j                  j                  |k7  rB| j                   j                  s| j                  j                  |¬«       | j                  «        | j                  «        y )Nr   r   r$   )r   r   )r   )r   r   r   r   r   r'   r(   Úupdater*   r   r"   )r   r   r   s      r   Ú_update_placement_groupz3AnsibleHCloudPlacementGroup._update_placement_groupš   së   € Ø{‰{×!Ñ!×%Ñ% fÓ-ˆØÐ × ;Ñ ;× @Ñ @ÀDÒ HØK‰K×.Ñ.À¸vÐ.ÔFØ—;‘;×)Ò)Ø×+Ñ+×2Ñ2¸Ð2Ô=Ø×!Ñ!Ô#à—‘×#Ñ#×'Ñ'¨Ó1ˆØÐ $×"=Ñ"=×"DÑ"DÈÒ"NØ—;‘;×)Ò)Ø×+Ñ+×2Ñ2¸&Ð2ÔAØ×!Ñ!Ô#à×!Ñ!Õ#r   c                ó~   — | j                  «        | j                  €| j                  «        y | j                  «        y ©N)r"   r   r+   r.   r   s    r   Úpresent_placement_groupz3AnsibleHCloudPlacementGroup.present_placement_groupª   s2   € Ø×!Ñ!Ô#Ø×&Ñ&Ð.Ø×(Ñ(Õ*à×(Ñ(Õ*r   c                óô   — | j                  «        | j                  U| j                  j                  s/| j                  j
                  j                  | j                  «       | j                  «        d | _        y r0   )r"   r   r   r(   r   r   Údeleter*   r   s    r   Údelete_placement_groupz2AnsibleHCloudPlacementGroup.delete_placement_group±   sY   € Ø×!Ñ!Ô#Ø×&Ñ&Ð2Ø—;‘;×)Ò)Ø—‘×,Ñ,×3Ñ3°D×4OÑ4OÔPØ×!Ñ!Ô#Ø&*ˆÕ#r   c                ó‚   •— t        t        dddiddiddiddiddgddœdœt        ‰|   «       ¤Žd	d
ggddd
gggd¬«      S )Nr   Úintr   ÚdictÚabsentÚpresent)ÚchoicesÚdefault)r   r   r   r   Ústater   r   r<   T)Úargument_specÚrequired_one_ofÚrequired_ifÚsupports_check_moder&   )r   r7   ÚsuperÚbase_module_arguments)ÚclsÚ	__class__s    €r   Údefine_modulez)AnsibleHCloudPlacementGroup.define_module¹   sz   ø€ äÜð 
Ø˜E?Ø˜e_Ø Ð'Ø˜e_à (¨)Ð4Ø(ññ
ô ‘'Ñ/Ó1ñ
ð # F˜^Ð,Ø! 9¨v¨hÐ7Ð8Ø $ô
ð 	
r   )Ú__name__Ú
__module__Ú__qualname__Ú	representr   Ú__annotations__r   r"   r+   r.   r1   r4   ÚclassmethodrE   Ú__classcell__)rD   s   @r   r
   r
   t   sF   ø… Ø(€Ià9=ÐÐ6Ó=ò
ò-ò$ò$ò +ò+ð ó
ó ô
r   r
   c                 ó  — t         j                  «       } t        | «      }| j                  j                  d«      }|dk(  r|j	                  «        n|dk(  r|j                  «         | j                  di |j                  «       ¤Ž y )Nr<   r8   r9   r&   )r
   rE   r   r   r4   r1   Ú	exit_jsonÚ
get_result)r   Úhcloudr<   s      r   ÚmainrQ   Í   sr   € Ü(×6Ñ6Ó8€Fä(¨Ó0€FØM‰M×Ñ˜gÓ&€EØÒØ×%Ñ%Õ'Ø	)Ò	Ø×&Ñ&Ô(à€F×ÑÑ+v×(Ñ(Ó*Ó+r   Ú__main__N)Ú
__future__r   ÚDOCUMENTATIONÚEXAMPLESÚRETURNÚansible.module_utils.basicr   Úmodule_utils.hcloudr   Úmodule_utils.vendor.hcloudr   Ú+module_utils.vendor.hcloud.placement_groupsr   r
   rQ   rF   r&   r   r   ú<module>r[      sW   ðõ #ð)€ðV€ð,!
€õF 5å /Ý 8Ý MôV
 -ô V
òr
,ð ˆzÒÙ…Fð r   