
    Vh                     `    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 Zedk(  r e        y	y	)
    )absolute_importdivisionprint_functiona  
module: gandi_livedns
author:
  - Gregory Thiemonge (@gthiemonge)
version_added: "2.3.0"
short_description: Manage Gandi LiveDNS records
description:
  - 'Manages DNS records by the Gandi LiveDNS API, see the docs: U(https://doc.livedns.gandi.net/).'
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  personal_access_token:
    description:
      - Scoped API token.
      - One of O(personal_access_token) and O(api_key) must be specified.
    type: str
    version_added: 9.0.0
  api_key:
    description:
      - Account API token.
      - Note that these type of keys are deprecated and might stop working at some point. Use personal access tokens instead.
      - One of O(personal_access_token) and O(api_key) must be specified.
    type: str
  record:
    description:
      - Record to add.
    type: str
    required: true
  state:
    description:
      - Whether the record(s) should exist or not.
    type: str
    choices: [absent, present]
    default: present
  ttl:
    description:
      - The TTL to give the new record.
      - Required when O(state=present).
    type: int
  type:
    description:
      - The type of DNS record to create.
    type: str
    required: true
  values:
    description:
      - The record values.
      - Required when O(state=present).
    type: list
    elements: str
  domain:
    description:
      - The name of the Domain to work with (for example, V(example.com)).
    required: true
    type: str
a'  
- name: Create a test A record to point to 127.0.0.1 in the my.com domain
  community.general.gandi_livedns:
    domain: my.com
    record: test
    type: A
    values:
      - 127.0.0.1
    ttl: 7200
    personal_access_token: dummytoken
  register: record

- name: Create a mail CNAME record to www.my.com domain
  community.general.gandi_livedns:
    domain: my.com
    type: CNAME
    record: mail
    values:
      - www
    ttl: 7200
    personal_access_token: dummytoken
    state: present

- name: Change its TTL
  community.general.gandi_livedns:
    domain: my.com
    type: CNAME
    record: mail
    values:
      - www
    ttl: 10800
    personal_access_token: dummytoken
    state: present

- name: Delete the record
  community.general.gandi_livedns:
    domain: my.com
    type: CNAME
    record: mail
    personal_access_token: dummytoken
    state: absent

- name: Use a (deprecated) API Key
  community.general.gandi_livedns:
    domain: my.com
    record: test
    type: A
    values:
      - 127.0.0.1
    ttl: 7200
    api_key: dummyapikey
a  
record:
  description: A dictionary containing the record data.
  returned: success, except on record deletion
  type: dict
  contains:
    values:
      description: The record content (details depend on record type).
      returned: success
      type: list
      elements: str
      sample:
        - 192.0.2.91
        - 192.0.2.92
    record:
      description: The record name.
      returned: success
      type: str
      sample: www
    ttl:
      description: The time-to-live for the record.
      returned: success
      type: int
      sample: 300
    type:
      description: The record type.
      returned: success
      type: str
      sample: A
    domain:
      description: The domain associated with the record.
      returned: success
      type: str
      sample: my.com
)AnsibleModule)GandiLiveDNSAPIc                     t        t        t        dd      t        dd      t        dd      t        ddddg      t        d	      t        dd      t        d
d      t        dd            dddddgfgdgdg      } t        |       }| j                  d   dk(  rZ|j	                  | j                  d   | j                  d   | j                  d   | j                  d   | j                  d         \  }}nK|j                  | j                  d   | j                  d   | j                  d   | j                  d         \  }}t        |      }|r"|j                  || j                  d         |d<    | j                  di | y )NstrT)typeno_log)r
   requiredpresentabsent)r
   defaultchoicesint)r
   list)r
   elements)api_keypersonal_access_tokenrecordstatettlr
   valuesdomainr   r   r   )r   r   )argument_specsupports_check_moderequired_ifmutually_exclusiverequired_one_ofr   r
   r   )changed )r   dictr   paramsensure_dns_recorddelete_dns_recordbuild_result	exit_json)module	gandi_apiretr    results        s/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/gandi_livedns.pymainr-      s   eD1"&E$"?UT2E9x>ST% 540Ve4UT2	
 !i(E!23
 1
 1
%F.  'I}}W* 226==3J39==3H39==3G39==3J39==3J	LW !226==3J39==3H39==3J39==3JLW
 F $11#28--2IKx Fv    __main__N)
__future__r   r   r   r
   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Lansible_collections.community.general.plugins.module_utils.gandi_livedns_apir   r-   __name__r!   r.   r,   <module>r8      sM    A @<|3j"
J 5 h-` zF r.   