Ë
    ÇVhø  ã                   ó¦   — 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
Z
d
Zd dlmZ d dlmZmZ d dlmZ d„ Zedk(  r e«        y	y	# e$ r dZY Œ.w xY w)é    )Úabsolute_importÚdivisionÚprint_functionz1.1ÚpreviewÚ	community)Úmetadata_versionÚstatusÚsupported_byaQ  
---
module: mso_rest
short_description: Direct access to the Cisco MSO REST API
description:
- Enables the management of the Cisco MSO fabric through direct access to the Cisco MSO REST API.
- This module is not idempotent and does not report changes.
options:
  method:
    description:
    - The HTTP method of the request.
    - Using C(delete) is typically used for deleting objects.
    - Using C(get) is typically used for querying objects.
    - Using C(post) is typically used for modifying objects.
    - Using C(put) is typically used for modifying existing objects.
    - Using C(patch) is typically also used for modifying existing objects.
    type: str
    choices: [ delete, get, post, put, patch ]
    default: get
    aliases: [ action ]
  path:
    description:
    - URI being used to execute API calls.
    type: str
    required: true
    aliases: [ uri ]
  content:
    description:
    - Sets the payload of the API request directly.
    - This may be convenient to template simple requests.
    - For anything complex use the C(template) lookup plugin (see examples).
    type: raw
    aliases: [ payload ]
extends_documentation_fragment:
- cisco.mso.modules

notes:
- Most payloads are known not to be idempotent, so be careful when constructing payloads.
seealso:
- module: cisco.mso.mso_tenant
author:
- Anvitha Jain (@anvitha-jain)
a-  
- name: Add schema (JSON)
  cisco.mso.mso_rest:
    host: mso
    username: admin
    password: SomeSecretPassword
    path: /mso/api/v1/schemas
    method: post
    content:
      {
        "displayName": "{{ mso_schema | default('ansible_test') }}",
        "templates": [{
          "name": "Template_1",
          "tenantId": "{{ add_tenant.jsondata.id }}",
          "displayName": "Template_1",
          "templateSubType": [],
          "templateType": "stretched-template",
          "anps": [],
          "contracts": [],
          "vrfs": [],
          "bds": [],
          "filters": [],
          "externalEpgs": [],
          "serviceGraphs": [],
          "intersiteL3outs": []
        }],
        "sites": [],
        "_updateVersion": 0
      }

- name: Query schema
  cisco.mso.mso_rest:
    host: mso
    username: admin
    password: SomeSecretPassword
    path: /mso/api/v1/schemas
    method: get
  register: query_result

- name: Patch schema (YAML)
  cisco.mso.mso_rest:
    host: mso
    username: admin
    password: SomeSecretPassword
    path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}"
    method: patch
    content:
      - op: add
        path: /templates/Template_1/anps/-
        value:
          name: AP2
          displayName: AP2
          epgs: []
        _updateVersion: 0

- name: Add a tenant from a templated payload file from templates
  cisco.mso.mso_rest:
    host: mso
    username: admin
    password: SomeSecretPassword
    method: post
    path: /api/v1/tenants
    content: "{{ lookup('template', 'mso/tenant.json.j2') }}"
ú
NTF)ÚAnsibleModule)Ú	MSOModuleÚmso_argument_spec)Úto_textc            	      óÖ  — t        «       } | j                  t        dddg¬«      t        ddg d¢dg¬«      t        d	d
g¬«      ¬«       t        | ¬«      }|j                  j                  d«      }|j                  j                  d«      }t        |«      }|r,t        |t        «      rt        r	 t        j                  |«      }|j                  j                  d«      j                  «       |_        |j"                  r||j$                  d<   n,|j'                  ||j                   |d ¬«      |j$                  d<   |j(                  |j$                  d<   |j                   dk7  r-d|j$                  d<   |j                   dk(  rd |j$                  d<    |j*                  di |j$                  ¤Ž y # t        $ r4}|j                  dt        |«      z  t        |«      |¬«       Y d }~Œ d }~ww xY w)NÚstrTÚuri)ÚtypeÚrequiredÚaliasesÚget)Údeleter   ÚpostÚputÚpatchÚaction)r   ÚdefaultÚchoicesr   ÚrawÚpayload)r   r   )ÚpathÚmethodÚcontent)Úargument_specr"   r    z.Failed to parse provided JSON/YAML payload: %s)ÚmsgÚ	exceptionr   r!   Újsondata)r!   ÚdataÚapi_versionr	   ÚGETÚchangedÚDELETE© )r   ÚupdateÚdictr   Úparamsr   r   Ú
isinstancer   ÚHAS_YAMLÚyamlÚ	safe_loadÚ	ExceptionÚ	fail_jsonr   Úupperr!   Ú
check_modeÚresultÚrequestr	   Ú	exit_json)r#   Úmoduler"   r    ÚmsoÚes         úf/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/mso/plugins/modules/mso_rest.pyÚmainr?   Š   sµ  € Ü%Ó'€MØ×ÑÜu t°e°WÔ=Ü˜¨Ò7`ÐksÐjtÔuÜ˜%¨)¨Ô5ð ô ô Ø#ô€Fð m‰m×Ñ 	Ó*€GØ=‰=×Ñ˜VÓ$€Dä
FÓ
€Cñ ”:˜g¤sÔ+µð	Gä—n‘n WÓ-ˆGð —‘—‘ Ó)×/Ñ/Ó1€C„Jð ×ÒØ!(ˆ
‰
:Òà!$§¡¨T¸#¿*¹*È7Ð`d Ó!eˆ
‰
:ÑàŸ:™:€C‡JJˆxÑà
‡zzUÒØ $ˆ
‰
9ÑØ:‰:˜Ò!Ø%)ˆCJ‰JzÑ"ð €C‡MMÑC—J‘JÓøô' ò 	GØ×ÑÐ!QÔT[Ð\]ÓT^Ñ!^ÔjqÐrsÓjtð  FÐ÷  Gò  Gûð	Gús   Â.F+ Æ+	G(Æ4)G#Ç#G(Ú__main__)Ú
__future__r   r   r   r   Ú__metaclass__ÚANSIBLE_METADATAÚDOCUMENTATIONÚEXAMPLESÚRETURNr2   r1   r4   Úansible.module_utils.basicr   Ú6ansible_collections.cisco.mso.plugins.module_utils.msor   r   Úansible.module_utils._textr   r?   Ú__name__r,   ó    r>   ú<module>rL      sƒ   ð÷ AÑ @à€à(-¸)¸ÐVaÑbÐ ð*€ðX?€ðB
€ðÛà€Hõ 5ß _Ý .ò) ðX ˆzÒÙ…Fð øði ò Ø‚Hðús   ›A ÁAÁA