
    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: certificate_info
short_description: Gather infos about your Hetzner Cloud certificates.
description:
    - Gather facts about your Hetzner Cloud certificates.
author:
    - Lukas Kaemmerling (@LKaemmerling)
options:
    id:
        description:
            - The ID of the certificate you want to get.
            - The module will fail if the provided ID is invalid.
        type: int
    name:
        description:
            - The name of the certificate you want to get.
        type: str
    label_selector:
        description:
            - The label selector for the certificate you want to get.
        type: str
extends_documentation_fragment:
- hetzner.hcloud.hcloud

z
- name: Gather hcloud certificate infos
  hetzner.hcloud.certificate_info:
  register: output
- name: Print the gathered infos
  debug:
    var: output.hcloud_certificate_info
a  
hcloud_certificate_info:
    description: The certificate instances
    returned: Always
    type: complex
    contains:
        id:
            description: Numeric identifier of the certificate
            returned: always
            type: int
            sample: 1937415
        name:
            description: Name of the certificate
            returned: always
            type: str
            sample: my website cert
        fingerprint:
            description: Fingerprint of the certificate
            returned: always
            type: str
            sample: "03:c7:55:9b:2a:d1:04:17:09:f6:d0:7f:18:34:63:d4:3e:5f"
        certificate:
            description: Certificate and chain in PEM format
            returned: always
            type: str
            sample: "-----BEGIN CERTIFICATE-----..."
        domain_names:
            description: List of Domains and Subdomains covered by the Certificate
            returned: always
            type: dict
        not_valid_before:
            description: Point in time when the Certificate becomes valid (in ISO-8601 format)
            returned: always
            type: str
        not_valid_after:
            description: Point in time when the Certificate stops being valid (in ISO-8601 format)
            returned: always
            type: str
        labels:
            description: User-defined labels (key-value pairs)
            returned: always
            type: dict
)AnsibleModule   )AnsibleHCloud)HCloudException)BoundCertificatec                  H     e Zd ZU dZdZded<   d Zd Ze fd       Z	 xZ
S )AnsibleHCloudCertificateInfohcloud_certificate_infoNzlist[BoundCertificate] | Nonec                P   g }| j                   D ]  }||j                  t        |j                        |j                  |j
                  |j                  |j                  j                         |j                  j                         |j                  |j                  d        |S )N)idnamefingerprintcertificatenot_valid_beforenot_valid_afterdomain_nameslabels)r   appendstrr   r   r   r   r   	isoformatr   r   r   )selftmpr   s      s/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/hetzner/hcloud/plugins/modules/certificate_info.py_prepare_resultz,AnsibleHCloudCertificateInfo._prepare_resulte   s    77 	K"JJknn-',,#.#:#:#.#:#:(3(D(D(N(N(P'2'B'B'L'L'N$/$<$<)00			  
    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                  d      O| j                  j                  j                  | j                   j                  j                  d            | _        y | j                  j                  j                         | _        y # t        $ r}| j                  |       Y d }~y d }~ww xY w)Nr   r   label_selector)r   )moduleparamsgetclientcertificates	get_by_idr   get_by_nameget_allr   fail_json_hcloud)r   	exceptions     r   get_certificatesz-AnsibleHCloudCertificateInfo.get_certificatesz   sE   	-{{!!%%d+7040H0H0R0RSWS^S^SeSeSiSijnSo0p/q,##''/;040H0H0T0TUYU`U`UgUgUkUklrUs0t/u,##''(89E/3{{/G/G/O/O#';;#5#5#9#9:J#K 0P 0, 04{{/G/G/O/O/Q, 	-!!),,	-s,   A3F 6A3F *A3F )F 	F,F''F,c           	     \    t        t        dddiddiddidt        |          d      S )Ntypeintr   )r   r   r   T)argument_specsupports_check_mode )r   dictsuperbase_module_arguments)cls	__class__s    r   define_modulez*AnsibleHCloudCertificateInfo.define_module   sI     E?e_ & '/1	 !%
 	
r   )__name__
__module____qualname__	representr   __annotations__r   r)   classmethodr5   __classcell__)r4   s   @r   r
   r
   `   s2    )I=A:A*-  	
 	
r   r
   c                     t         j                         } t        |       }|j                          |j                         }d|d   i} | j                  di | y )Nr   r/   )r
   r5   r)   
get_result	exit_json)r   hcloudresultansible_infos       r   mainrC      sW    )779F)&1F
 F-v6O/PQLF$|$r   __main__N)
__future__r   DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   module_utils.hcloudr   module_utils.vendor.hcloudr   'module_utils.vendor.hcloud.certificatesr   r
   rC   r6   r/   r   r   <module>rM      sT    #6*
X 5 / 8 F4
= 4
n% zF r   