
    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: server
short_description: Update server information
version_added: 1.2.0
author:
  - Felix Fontein (@felixfontein)
description:
  - Allows to update server information.
  - Right now the API only supports updating the server's name.
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: none
  idempotent:
    support: full

options:
  server_number:
    description:
      - The server number of the server to update.
    type: int
    required: true
  server_name:
    description:
      - The server's name.
      - If this option is not provided, it will not be adjusted.
    type: str
z
---
- name: Set server's name to foo.example.com
  community.hrobot.server:
    hetzner_user: foo
    hetzner_password: bar
    server_number: 123
    server_name: foo.example.com
a  
server:
  description:
    - Information on the server.
  returned: success
  type: dict
  contains:
    server_ip:
      description:
        - The server's main IP address.
      type: str
      sample: 123.123.123.123
      returned: success
    server_ipv6_net:
      description:
        - The server's main IPv6 network address.
      type: str
      sample: '2a01:f48:111:4221::'
      returned: success
    server_number:
      description:
        - The server's numeric ID.
      type: int
      sample: 321
      returned: success
    server_name:
      description:
        - The user-defined server's name.
      type: str
      sample: server1
      returned: success
    product:
      description:
        - The server product name.
      type: str
      sample: EQ 8
      returned: success
    dc:
      description:
        - The data center the server is located in.
      type: str
      sample: NBG1-DC1
      returned: success
    traffic:
      description:
        - Free traffic quota.
        - V(unlimited) in case of unlimited traffic.
      type: str
      sample: 5 TB
      returned: success
    status:
      description:
        - Server status.
      type: str
      choices:
        - ready
        - in process
      sample: ready
      returned: success
    cancelled:
      description:
        - Whether the server is cancelled.
      type: bool
      sample: false
      returned: success
    paid_until:
      description:
        - The date until the server has been paid.
      type: str
      sample: "2018-08-04"
      returned: success
    ip:
      description:
        - List of assigned single IP addresses.
      type: list
      elements: str
      sample:
        - 123.123.123.123
      returned: success
    subnet:
      description:
        - List of assigned subnets.
      type: list
      elements: dict
      sample:
        - ip: '2a01:4f8:111:4221::'
          mask: 64
      contains:
        ip:
          description:
            - The first IP in the subnet.
          type: str
          sample: '2a01:4f8:111:4221::'
        mask:
          description:
            - The masks bitlength.
          type: str
          sample: "64"
      returned: success
    reset:
      description:
        - Whether the server can be automatically reset.
      type: bool
      sample: true
      returned: success
    rescue:
      description:
        - Whether the rescue system is available.
      type: bool
      sample: false
      returned: success
    vnc:
      description:
        - Flag of VNC installation availability.
      type: bool
      sample: true
      returned: success
    windows:
      description:
        - Flag of Windows installation availability.
      type: bool
      sample: true
      returned: success
    plesk:
      description:
        - Flag of Plesk installation availability.
      type: bool
      sample: true
      returned: success
    cpanel:
      description:
        - Flag of cPanel installation availability.
      type: bool
      sample: true
      returned: success
    wol:
      description:
        - Flag of Wake On Lan availability.
      type: bool
      sample: true
      returned: success
    hot_swap:
      description:
        - Flag of Hot Swap availability.
      type: bool
      sample: true
      returned: success
    linked_storagebox:
      description:
        - Linked Storage Box ID.
      type: int
      sample: 12345
      returned: success
)AnsibleModule)	urlencode)BASE_URLROBOT_DEFAULT_ARGUMENT_SPECfetch_url_jsonc                     t        t        dd      t        d            } | j                  t               t        | d      }|j                  d   }|j                  d	   }d
j                  t        |      }t        ||dg      \  }}|r|j                  d       d|d   d}i }|||d   d	   k7  r||d	<   |rd|d<   |j                  r|d   j                  |       nrddi}	d
j                  t        |      }t        ||t        |      |	ddg      \  }}|r0|j                  dj                  |j                  |                   |d   |d<    |j                  di | y )NintT)typerequiredstr)r   )server_numberserver_name)argument_specsupports_check_moder   r   z{0}/server/{1}SERVER_NOT_FOUND)accept_errorszCThis server does not exist, or you do not have access rights for it)msgFserver)changedr   r   zContent-typez!application/x-www-form-urlencodedPOSTINVALID_INPUT)dataheadersmethodr   z'The values to update were invalid ({0}) )dictupdater	   r   paramsformatr   r
   	fail_json
check_moder   jsonify	exit_json)
r   moduler   r   urlr   errorresultr    r   s
             k/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/hrobot/plugins/modules/server.pymainr,      s   5e$M 45# F
 MM/2M--.K

!
!(M
:C"63?Q>RSMFEbc "F
 F&*=99$/F=! y8##F+%'JKG"))(MBC*v&./MFE   %N%U%UV\VdVdekVl%m n%h/F8Fv    __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   +ansible.module_utils.six.moves.urllib.parser   ?ansible_collections.community.hrobot.plugins.module_utils.robotr   r	   r
   r,   __name__r   r-   r+   <module>r8      sW    A @#JY
v 5 A 0f zF r-   