
    Vh!                     r    d dl mZmZmZ eZddgddZdZdZdZ	d d	l
mZ d d
lmZmZ d Zedk(  r e        yy)    )absolute_importdivisionprint_functionz1.1preview	community)metadata_versionstatussupported_bya  
---
module: mso_site
short_description: Manage sites
description:
- Manage sites on Cisco ACI Multi-Site.
author:
- Dag Wieers (@dagwieers)
options:
  apic_password:
    description:
    - The password for the APICs.
    - The apic_password attribute is not supported when using with ND platform.
    - See the ND collection for complete site management.
    type: str
  apic_site_id:
    description:
    - The site ID of the APICs.
    type: str
  apic_username:
    description:
    - The username for the APICs.
    - The apic_username attribute is not supported when using with ND platform.
    - See the ND collection for complete site management.
    type: str
    default: admin
  apic_login_domain:
    description:
    - The AAA login domain for the username for the APICs.
    - The apic_login_domain attribute is not supported when using with ND platform.
    - See the ND collection for complete site management.
    type: str
  site:
    description:
    - The name of the site.
    type: str
    aliases: [ name ]
  labels:
    description:
    - The labels for this site.
    - Labels that do not already exist will be automatically created.
    - The labels attribute is not supported when using with ND platform.
    - See the ND collection for complete site management.
    type: list
    elements: str
  location:
    description:
    - Location of the site.
    - The location attribute is not supported when using with ND platform.
    - See the ND collection for complete site management.
    type: dict
    suboptions:
      latitude:
        description:
        - The latitude of the location of the site.
        type: float
      longitude:
        description:
        - The longitude of the location of the site.
        type: float
  urls:
    description:
    - A list of URLs to reference the APICs.
    - The urls attribute is not supported when using with ND platform.
    - See the ND collection for complete site management.
    type: list
    elements: str
  state:
    description:
    - Use C(present) or C(absent) for adding or removing.
    - Use C(query) for listing an object or multiple objects.
    type: str
    choices: [ absent, present, query ]
    default: present
extends_documentation_fragment: cisco.mso.modules
a  
- name: Add a new site
  cisco.mso.mso_site:
    host: mso_host
    username: admin
    password: SomeSecretPassword
    site: north_europe
    description: North European Datacenter
    apic_username: mso_admin
    apic_password: AnotherSecretPassword
    apic_site_id: 12
    urls:
      - 10.2.3.4
      - 10.2.4.5
      - 10.3.5.6
    labels:
      - NEDC
      - Europe
      - Diegem
    location:
      latitude: 50.887318
      longitude: 4.447084
    state: present

- name: Remove a site
  cisco.mso.mso_site:
    host: mso_host
    username: admin
    password: SomeSecretPassword
    site: north_europe
    state: absent

- name: Query a site
  cisco.mso.mso_site:
    host: mso_host
    username: admin
    password: SomeSecretPassword
    site: north_europe
    state: query
  register: query_result

- name: Query all sites
  cisco.mso.mso_site:
    host: mso_host
    username: admin
    password: SomeSecretPassword
    state: query
  register: query_result

)AnsibleModule)	MSOModulemso_argument_specc                  	   t        t        d      t        d            } t               }|j                  t        dd      t        d      t        dd      t        d      t        d	d
      t        d|       t        ddg      t        ddg d      t        d	d
      	       t        |ddddggddddggg      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }|<|j                  j                  d      d   }|j                  j                  d      d   }	|j                  j                  d      }
|j                  j                  d      }|j                  j                  d      }t        |      }d }d}d }|j                  d!k(  rd"}|j                  |j                  j                  d#      d      }|r|j                  d!k(  rT|j                  ||t        |$      %      }d&}|r|j                  d'      }||d(k7  r||_
        d)j                  |*      }nj|j                  ||$      |_
        |j                  rF|j                  j                  d'      }d+j                  |*      }n|j                  ||,      |_
        |
d-k(  rn|
dk(  r[|j                  |_        |j                  r|j                  r	i |_
        n|j                  |d.t        d/0      |1       i |_
        na|
dk(  r[|j                  |_        |j                  d!k(  rH|j                  r|j                  }nnr|}||d2   d3<   na|j!                  d4j                  |      5       n?t        |||||||6      }|t        	7      |d<   ||d8vrd9j                  ||      |d:<   |j#                  d;       |j                  rS|j%                         r|j                  r|j&                  |_
        ng|j                  |d<|j(                  |=      |_
        nB|j                  r|j&                  |_
        n$|j                  |d>|j(                  |=      |_
        d?|j                  v rd@|j                  d?<   |j+                          y )ANfloat)type)latitude	longitudestrT)r   no_logadmin)r   defaultlist)r   elementsdict)r   optionsname)r   aliasespresent)absentr   query)r   r   choices)	apic_passwordapic_site_idapic_usernameapic_login_domainlabelslocationsitestateurlsr)   r   r(   r#   )argument_specsupports_check_moderequired_ifr$   r"   r'   r   r   r*   r%   sitesv1ndv2r&   )r   )api_versioncommonzsites/manageid zsites/manage/{id})r4   z
sites/{id})r2   r    DELETEtrue)force)methodqsr2   r3   siteIdzLSite '{0}' is not a valid Site configured at ND-level. Add Site to ND first.)msg)
apicSiteIdr4   r   r*   r&   usernamepassword)latlong)r5   localLocalzapic#{0}\{1}r>   )collatePUT)r9   datar2   POSTr?   z******)r   r   updater   paramsgetr   platformlookup_labelsget_objexistingformat
query_objsprevious
check_moderequest	fail_jsonsanitizecheck_changedproposedsent	exit_json)location_arg_specr+   moduler$   r"   r#   r(   r'   r   r   r)   r*   r%   msosite_idpathr2   r&   	site_infopayloads                       f/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/mso/plugins/modules/mso_site.pymainrb      s   7#G$
 &'Md3u%w7E*%06+<=uvh/y:XYv.  
 # h)i.&!9:
F MM%%o6MMM%%o6M==$$^4L==V$D}}  ,H==$$Z0<MM%%j1+>	MMg&E==V$D))*=>
F
CGDK
||t v}}00:FCF <<4Dk$TX/ZI!D#---&7b=#,CL.555AD;;t$;7CL||,,**40#**g*6 ~~d~D	(	||<<  !Dd6HVab!	)	||<<4||,,'G2>GH%h/MM&t&{&{  }A  'BM  C '&&G #&* "'
#
 !,1BJ`1`&5&<&<=NP]&^
#Wd+<<  "$$#&<<CL#&;;tE^i;#jCL  "||"{{4SXX[f{gS\\!#+Z MMO    __main__N)
__future__r   r   r   r   __metaclass__ANSIBLE_METADATADOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   6ansible_collections.cisco.mso.plugins.module_utils.msor   r   rb   __name__ rc   ra   <module>ro      s^    A @(-)Vab KZ0d
 5 _GT zF rc   