
    Vh!                         d dl mZmZmZ eZdZdZdZd dl	Z	d dl
mZmZ dZ	 d dlZd dlmZ dZd
 Zd Zedk(  r e        yy# e$ r  e	j$                         Zd	ZY .w xY w)    )absolute_importdivisionprint_functiona!	  
module: netcup_dns
notes: []
short_description: Manage Netcup DNS records
description:
  - Manages DNS records using the Netcup API, see the docs U(https://ccp.netcup.net/run/webservice/servers/endpoint.php).
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  api_key:
    description:
      - API key for authentication, must be obtained using the netcup CCP (U(https://ccp.netcup.net)).
    required: true
    type: str
  api_password:
    description:
      - API password for authentication, must be obtained using the netcup CCP (U(https://ccp.netcup.net)).
    required: true
    type: str
  customer_id:
    description:
      - Netcup customer ID.
    required: true
    type: int
  domain:
    description:
      - Domainname the records should be added / removed.
    required: true
    type: str
  record:
    description:
      - Record to add or delete, supports wildcard (V(*)). Default is V(@) (that is, the zone name).
    default: "@"
    aliases: [name]
    type: str
  type:
    description:
      - Record type.
      - Support for V(OPENPGPKEY), V(SMIMEA) and V(SSHFP) was added in community.general 8.1.0.
      - Record types V(OPENPGPKEY) and V(SMIMEA) require nc-dnsapi >= 0.1.5.
      - Record type V(SSHFP) requires nc-dnsapi >= 0.1.6.
    choices: ['A', 'AAAA', 'MX', 'CNAME', 'CAA', 'SRV', 'TXT', 'TLSA', 'NS', 'DS', 'OPENPGPKEY', 'SMIMEA', 'SSHFP']
    required: true
    type: str
  value:
    description:
      - Record value.
    required: true
    type: str
  solo:
    type: bool
    default: false
    description:
      - Whether the record should be the only one for that record type and record name. Only use with O(state=present).
      - This will delete all other records with the same record name and type.
  priority:
    description:
      - Record priority. Required for O(type=MX).
    required: false
    type: int
  state:
    description:
      - Whether the record should exist or not.
    required: false
    default: present
    choices: ['present', 'absent']
    type: str
  timeout:
    description:
      - HTTP(S) connection timeout in seconds.
    default: 5
    type: int
    version_added: 5.7.0
requirements:
  - "nc-dnsapi >= 0.1.3"
author: "Nicolai Buchwitz (@nbuchwitz)"
al  
- name: Create a record of type A
  community.general.netcup_dns:
    api_key: "..."
    api_password: "..."
    customer_id: "..."
    domain: "example.com"
    name: "mail"
    type: "A"
    value: "127.0.0.1"

- name: Delete that record
  community.general.netcup_dns:
    api_key: "..."
    api_password: "..."
    customer_id: "..."
    domain: "example.com"
    name: "mail"
    type: "A"
    value: "127.0.0.1"
    state: absent

- name: Create a wildcard record
  community.general.netcup_dns:
    api_key: "..."
    api_password: "..."
    customer_id: "..."
    domain: "example.com"
    name: "*"
    type: "A"
    value: "127.0.1.1"

- name: Set the MX record for example.com
  community.general.netcup_dns:
    api_key: "..."
    api_password: "..."
    customer_id: "..."
    domain: "example.com"
    type: "MX"
    value: "mail.example.com"

- name: Set a record and ensure that this is the only one
  community.general.netcup_dns:
    api_key: "..."
    api_password: "..."
    customer_id: "..."
    name: "demo"
    domain: "example.com"
    type: "AAAA"
    value: "::1"
    solo: true

- name: Increase the connection timeout to avoid problems with an unstable connection
  community.general.netcup_dns:
    api_key: "..."
    api_password: "..."
    customer_id: "..."
    domain: "example.com"
    name: "mail"
    type: "A"
    value: "127.0.0.1"
    timeout: 30
a  
records:
  description: List containing all records.
  returned: success
  type: list
  elements: dict
  contains:
    name:
      description: The record name.
      returned: success
      type: str
      sample: fancy-hostname
    type:
      description: The record type.
      returned: success
      type: str
      sample: A
    value:
      description: The record destination.
      returned: success
      type: str
      sample: 127.0.0.1
    priority:
      description: The record priority (only relevant if RV(records[].type=MX)).
      returned: success
      type: int
      sample: 0
    id:
      description: Internal ID of the record.
      returned: success
      type: int
      sample: 12345
N)AnsibleModulemissing_required_lib)	DNSRecordTFc                  J   t        t        t        dd      t        dd      t        dd      t        d      t        dddg	      t        dg d
      t        d      t        dd      t        ddd      t        dddgd      t        ddd            d      } t        s | j                  t	        d      t
               | j                  j                  d      }| j                  j                  d      }| j                  j                  d      }| j                  j                  d      }| j                  j                  d      }| j                  j                  d      }| j                  j                  d      }| j                  j                  d      }| j                  j                  d      }	| j                  j                  d      }
| j                  j                  d       }|d!k(  r|s| j                  d"#       d}g }	 t        j                  ||||      5 }|j                  |      }t        ||||$      }d}|D ]  }||k(  s	d}|} n |
dk(  r|	r||D cg c]O  }|j                  |j                  k(  r4|j                  |j                  k(  r|j                  |j                  k(  s|Q }}|r | j                  s|j!                  ||      }d}|sH| j                  s|j#                  ||      }d}n'|
dk(  r"|r | j                  s|j%                  ||      }d}d d d        | j+                  |d%|D cg c]  }t-        |       c}i&       y c c}w # 1 sw Y   ;xY w# t&        $ r%}| j                  t)        |      #       Y d }~gd }~ww xY wc c}w )'NT)requiredno_logint)r
   type)r
   F@name)r
   defaultaliases)AAAAAMXCNAMECAASRVTXTTLSANSDS
OPENPGPKEYSMIMEASSHFP)r
   choicesbool)r
   r   r   presentabsent)r
   r   r      )api_keyapi_passwordcustomer_iddomainrecordr   valueprioritysolostatetimeout)argument_specsupports_check_modez	nc-dnsapi)msg	exceptionr$   r%   r&   r'   r   r(   r)   r*   r+   r,   r-   r   z/record type MX required the 'priority' argument)r0   )r*   records)changedresult)r   dictHAS_NCDNSAPI	fail_jsonr   NCDNSAPI_IMP_ERRparamsget	nc_dnsapiClientdns_recordsr   hostnamer   destination
check_modedelete_dns_recordsadd_dns_recorddelete_dns_record	Exceptionstr	exit_jsonrecord_data)moduler$   r%   r&   r'   record_typer(   r)   r*   r+   r,   r-   has_changedall_recordsapirecord_existsrobsolete_recordsexs                      p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/netcup_dns.pymainrR      sf   $t4tD9d7&fXFt .7 8 %5u5u65A	8/DiX%eQ?
" !%F* 1+>JZ[mm	*G==$$^4L--##M2K]]x(F--##F+K]]x(FMMg&E}}  ,H==V$DMMg&Emm	*Gd8NOKK'&k7L'J #	#c//&1Kv{EHMF "M  ;$(MF 	!3> (Ua()

foo(E,-FFfkk,A01ASAS0S )* (U$ (U
 (%00*-*@*@IY*ZK&*$!,,&)&8&8&H"&K("}(("%"7"7"GK"G#	#P [)Va=bQRk!n=b1cd3(U#	# #	#J  &SW%%& >csP   M/ '-M#M#'AM;A.M#)M/ N M##M,(M/ /	N8NNc                 v    | j                   | j                  | j                  | j                  | j                  dS )N)r   r   r)   r*   id)r>   r   r?   r*   rT   )rN   s    rQ   rG   rG   &  s-    JJTUT^T^fgfjfjkk    __main__)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURN	tracebackansible.module_utils.basicr   r   r8   r;   r   r6   ImportError
format_excrR   rG   __name__ rU   rQ   <module>rb      s    A @Qf>@ 
D  J #LSell zF   +y++-Ls   A AA