
    Vh                     h    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 d Zedk(  r e        y	y	)
    )absolute_importdivisionprint_functiona%  
module: server_info
short_description: Query information on one or more servers
version_added: 1.2.0
author:
  - Felix Fontein (@felixfontein)
description:
  - Query information on one or more servers.
extends_documentation_fragment:
  - community.hrobot.robot
  - community.hrobot.attributes
  - community.hrobot.attributes.actiongroup_robot
  - community.hrobot.attributes.idempotent_not_modify_state
  - community.hrobot.attributes.info_module

attributes:
  action_group:
    version_added: 1.6.0

options:
  server_number:
    description:
      - Limit result list to server with this number.
    type: int
  server_name:
    description:
      - Limit result list to servers of this name.
    type: str
  full_info:
    description:
      - Whether to provide full information for every server.
      - Setting this to V(true) requires one REST call per server, which is slow and reduces your rate limit. Use with care.
      - When O(server_number) is specified, this option is always treated as having value V(true).
    type: bool
    default: false
a  
---
- name: Query a list of all servers
  community.hrobot.server_info:
    hetzner_user: foo
    hetzner_password: bar
  register: result

- name: Query a specific server
  community.hrobot.server_info:
    hetzner_user: foo
    hetzner_password: bar
    server_number: 23
  register: result

- name: Output data on specific server
  ansible.builtin.debug:
    msg: "Server name: {{ result.servers[0].server_name }}"
aG  
servers:
  description:
    - List of servers matching the provided options.
  returned: success
  type: list
  elements: 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: when O(full_info=true)
    rescue:
      description:
        - Whether the rescue system is available.
      type: bool
      sample: false
      returned: when O(full_info=true)
    vnc:
      description:
        - Flag of VNC installation availability.
      type: bool
      sample: true
      returned: when O(full_info=true)
    windows:
      description:
        - Flag of Windows installation availability.
      type: bool
      sample: true
      returned: when O(full_info=true)
    plesk:
      description:
        - Flag of Plesk installation availability.
      type: bool
      sample: true
      returned: when O(full_info=true)
    cpanel:
      description:
        - Flag of cPanel installation availability.
      type: bool
      sample: true
      returned: when O(full_info=true)
    wol:
      description:
        - Flag of Wake On Lan availability.
      type: bool
      sample: true
      returned: when O(full_info=true)
    hot_swap:
      description:
        - Flag of Hot Swap availability.
      type: bool
      sample: true
      returned: when O(full_info=true)
    linked_storagebox:
      description:
        - Linked Storage Box ID.
      type: int
      sample: 12345
      returned: when O(full_info=true)
)AnsibleModule)BASE_URLROBOT_DEFAULT_ARGUMENT_SPECfetch_url_jsonc                     t        t        d      t        d      t        dd            } | j                  t               t        | d	      }|j                  d
   }|j                  d   }|j                  d   }g }||g}nndj                  t              }t        ||dg      \  }}	g }|	sC|D ]>  }
||
d   d   |k7  r|r|j                  |
d   d
          +|j                  |
d          @ |D ]O  }dj                  t        |      }t        ||dg      \  }}	|	r.||d   d   |k7  r<|j                  |d          Q |j                  d|       y )Nint)typestrboolF)r   default)server_numberserver_name	full_infoT)argument_specsupports_check_moder   r   r   z
{0}/serverSERVER_NOT_FOUND)accept_errorsserverz{0}/server/{1})changedservers)
dictupdater   r   paramsformatr   r	   append	exit_json)r   moduler   r   r   r   server_numbersurlresulterrorentrys              p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/hrobot/plugins/modules/server_info.pymainr'      s   &e$FE2M
 45# F
 MM/2M--.Kk*IG '!!(+&vsCUBVW 4*X}5D "))%//*JKNN5?34 ( -%%h>&vsCUBVW&(#M2kANN6(+,-       __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   ?ansible_collections.community.hrobot.plugins.module_utils.robotr   r   r	   r'   __name__ r(   r&   <module>r3      sT    A @#J(Z
x 5 -` zF r(   