
    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)    )annotationsa  
---
module: iso_info

short_description: Gather infos about the Hetzner Cloud ISO list.

description:
    - Gather infos about the Hetzner Cloud ISO list.

author:
    - Patrice Le Guyader (@patlegu)
    - Lukas Kaemmerling (@LKaemmerling)

options:
    id:
        description:
            - The ID of the ISO image you want to get.
            - The module will fail if the provided ID is invalid.
        type: int
    name:
        description:
            - The name of the ISO you want to get.
        type: str
    architecture:
        description:
            - Filter ISOs with compatible architecture.
        type: str
        choices: [x86, arm]
    include_architecture_wildcard:
        description:
            - Include ISOs with wildcard architecture (architecture is null).
            - Works only if architecture filter is specified.
        type: bool

extends_documentation_fragment:
    - hetzner.hcloud.hcloud
z
- name: Gather hcloud ISO type infos
  hetzner.hcloud.iso_info:
  register: output

- name: Print the gathered infos
  debug:
    var: output.hcloud_iso_info
a9
  
hcloud_iso_info:
    description: The ISO type infos as list
    returned: always
    type: complex
    contains:
        id:
            description: ID of the ISO
            returned: always
            type: int
            sample: 22110
        name:
            description: Unique identifier of the ISO. Only set for public ISOs
            returned: always
            type: str
            sample: debian-12.0.0-amd64-netinst.iso
        description:
            description: Description of the ISO
            returned: always
            type: str
            sample: Debian 12.0 (amd64/netinstall)
        architecture:
            description: >
                Type of cpu architecture this ISO is compatible with.
                None indicates no restriction on the architecture (wildcard).
            returned: when supported
            type: str
            sample: x86
        type:
            description: Type of the ISO, can be one of `public`, `private`.
            returned: always
            type: str
            sample: public
        deprecated:
            description: >
                ISO 8601 timestamp of deprecation, None if ISO is still available.
                After the deprecation time it will no longer be possible to attach the
                ISO to servers. This field is deprecated. Use `deprecation` instead.
            returned: always
            type: str
            sample: "2024-12-01T00:00:00+00:00"
        deprecation:
            description: >
                Describes if, when & how the resources was deprecated. If this field is
                set to None the resource is not deprecated. If it has a value, it is
                considered deprecated.
            returned: if the resource is deprecated
            type: dict
            contains:
                announced:
                    description: Date of when the deprecation was announced.
                    returned: always
                    type: str
                    sample: "2021-11-01T00:00:00+00:00"
                unavailable_after:
                    description: >
                      After the time in this field, the resource will not be available
                      from the general listing endpoint of the resource type, and it can
                      not be used in new resources. For example, if this is an image,
                      you can not create new servers with this image after the mentioned
                      date.
                    returned: always
                    type: str
                    sample: "2021-12-01T00:00:00+00:00"
)AnsibleModule   )AnsibleHCloud)HCloudException)BoundIsoc                  H     e Zd ZU dZdZded<   d Zd Ze fd       Z	 xZ
S )AnsibleHCloudIsoInfohcloud_iso_infoNzlist[BoundIso] | Nonec                   g }| j                   D ]  }||j                  t        |j                        |j                  |j
                  |j                  |j                  |j                  $|j                  j                  j                         nd |j                  I|j                  j                  j                         |j                  j                  j                         dnd d        |S )N)	announcedunavailable_after)idnamedescriptiontypearchitecture
deprecateddeprecation)r   appendstrr   r   r   r   r   r   r   	isoformatr   )selftmpiso_infos      k/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/hetzner/hcloud/plugins/modules/iso_info.py_prepare_resultz$AnsibleHCloudIsoInfo._prepare_result   s    ,, 	HJJhkk*$MM#+#7#7$MM$,$9$9NVNbNbNn,,>>HHJtx $//; *2)=)=)G)G)Q)Q)S191E1E1W1W1a1a1c
 "		2 
    c                   	 | j                   j                  j                  d      O| j                  j                  j                  | j                   j                  j                  d            g| _        y | j                   j                  j                  d      O| j                  j                  j                  | j                   j                  j                  d            g| _        y | j                  j                  j                  | j                   j                  j                  d      | j                   j                  j                  d            | _        y # t        $ r}| j                  |       Y d }~y d }~ww xY w)Nr   r   r   include_wildcard_architecture)r   include_architecture_wildcard)moduleparamsgetclientisos	get_by_idr   get_by_nameget_allr   fail_json_hcloud)r   	exceptions     r   get_iso_infosz"AnsibleHCloudIsoInfo.get_iso_infos   s    	-{{!!%%d+7(,(8(8(B(B4;;CUCUCYCYZ^C_(`'a$##''/;(,(8(8(D(DT[[EWEWE[E[\bEc(d'e$'+{{'7'7'?'?!%!3!3!7!7!G26++2D2D2H2HIh2i (@ ($
  	-!!),,	-s&   A3E 6A3E *A2E 	F&E<<Fc           
     h    t        t        dddiddidddgdddidt        |          d	
      S )Nr   intr   x86arm)r   choicesbool)r   r   r   r!   T)argument_specsupports_check_mode )r   dictsuperbase_module_arguments)cls	__class__s    r   define_modulez"AnsibleHCloudIsoInfo.define_module   sV     E?e_&+G/5v.>	
 '/1 !%	
 		
r   )__name__
__module____qualname__	representr   __annotations__r   r,   classmethodr;   __classcell__)r:   s   @r   r
   r
      s1    !I-1O*1<- 

 

r   r
   c                     t         j                         } t        |       }|j                          |j                         }d|d   i} | j                  di | y )Nr   r5   )r
   r;   r,   
get_result	exit_json)r"   hcloudresultansible_infos       r   mainrI      sW    !//1F!&)F
 F%v.?'@ALF$|$r   __main__N)
__future__r   DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   module_utils.hcloudr   module_utils.vendor.hcloudr   module_utils.vendor.hcloud.isosr   r
   rI   r<   r5   r   r   <module>rS      sV    #$L@
D 5 / 8 6=
= =
@% zF r   