
    Vh                     t    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 d dlmZmZmZ d Zed	k(  r e        y
y
)    )absolute_importdivisionprint_functiona  
module: failover_ip
short_description: Manage Hetzner's failover IPs
author:
  - Felix Fontein (@felixfontein)
description:
  - Manage Hetzner's failover IPs.
seealso:
  - name: Failover IP documentation
    description: Hetzner's documentation on failover IPs.
    link: https://docs.hetzner.com/robot/dedicated-server/ip/failover/
  - module: community.hrobot.failover_ip_info
    description: Retrieve information on failover IPs.
extends_documentation_fragment:
  - community.hrobot.robot
  - community.hrobot.attributes
  - community.hrobot.attributes.actiongroup_robot

attributes:
  action_group:
    version_added: 1.6.0
  check_mode:
    support: full
  diff_mode:
    support: full
  idempotent:
    support: full

options:
  failover_ip:
    description: The failover IP address.
    type: str
    required: true
  state:
    description:
      - Defines whether the IP will be routed or not.
      - If set to V(routed), O(value) must be specified.
    type: str
    choices:
      - routed
      - unrouted
    default: routed
  value:
    description:
      - The new value for the failover IP address.
      - Required when setting O(state) to V(routed).
    type: str
  timeout:
    description:
      - Timeout to use when routing or unrouting the failover IP.
      - Note that the API call returns when the failover IP has been successfully routed to the new address, respectively
        successfully unrouted.
    type: int
    default: 180
ah  
---
- name: Set value of failover IP 1.2.3.4 to 5.6.7.8
  community.hrobot.failover_ip:
    hetzner_user: foo
    hetzner_password: bar
    failover_ip: 1.2.3.4
    value: 5.6.7.8

- name: Set value of failover IP 1.2.3.4 to unrouted
  community.hrobot.failover_ip:
    hetzner_user: foo
    hetzner_password: bar
    failover_ip: 1.2.3.4
    state: unrouted
z
value:
  description:
    - The value of the failover IP.
    - Will be V(none) if the IP is unrouted.
  returned: success
  type: str
state:
  description:
    - Will be V(routed) or V(unrouted).
  returned: success
  type: str
)AnsibleModule)ROBOT_DEFAULT_ARGUMENT_SPEC)get_failoverset_failoverget_failover_statec            	      &   t        t        dd      t        ddddg      t        d      t        dd	
            } | j                  t               t        | ddddgff      }|j                  d   }t        ||      }d}t        |      }|j                  d   dk(  r|j                  d   }nd }||k7  r0|j                  r|}d}nt        ||||j                  d         \  }}t        |      } |j                  d|t        ||      d| y )NstrT)typerequiredroutedunrouted)r   defaultchoices)r   int   )r   r   )failover_ipstatevaluetimeoutr   r   )argument_specsupports_check_moderequired_ifr   Fr   )r   )beforeafter)changeddiff )
dictupdater   r   paramsr   r
   
check_moder	   	exit_json)r   moduler   r   r   r   	new_valuer   s           p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/hrobot/plugins/modules/failover_ip.pymainr)   n   s0   ed3x(J9OP%-	M 45# h	*
F --.K-EG&F}}W)MM'*			EG)&+yRXR_R_`iRjkNE7u%EF 
     __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   ?ansible_collections.community.hrobot.plugins.module_utils.robotr   Bansible_collections.community.hrobot.plugins.module_utils.failoverr   r	   r
   r)   __name__r    r*   r(   <module>r5      sW    A @6p"
 5 )X zF r*   