
    Vh	                     x    d dl mZmZmZ eZdZd dlZd dlm	Z	 d dl
mZ d dlmZ d dlmZ dZ G d	 d
e      Zd Zy)    )absolute_importdivisionprint_functiona  
author:
 - Ansible Networking Team (@ansible-network)
name: restconf
short_description: HttpApi Plugin for devices supporting Restconf API
description:
- This HttpApi plugin provides methods to connect to Restconf API endpoints.
version_added: 1.0.0
options:
  root_path:
    type: str
    description:
    - Specifies the location of the Restconf root.
    default: /restconf
    vars:
    - name: ansible_httpapi_restconf_root
N)to_text)ConnectionError)	HTTPError)HttpApiBasezapplication/yang-data+jsonc                       e Zd Zd Zy)HttpApic                    |rt        j                  |      }dj                  | j                  d      j	                  d      |j                  dd      j                  d      g      }|j                  d      xs t        |j                  d      xs t        d}| j                  j                  ||||j                  d      	      \  }}t        ||      S )
N/	root_pathpath content_typeaccept)zContent-TypeAcceptmethod)headersr   )jsondumpsjoin
get_optionrstripgetlstripCONTENT_TYPE
connectionsendhandle_response)selfdatamessage_kwargsr   r   responseresponse_datas          n/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ansible/netcommon/plugins/httpapi/restconf.pysend_requestzHttpApi.send_request)   s    ::d#Dxx,33C8""62.55c:
 +..~>N,$((2Bl
 #'//"6"6$0B0B80L #7 #
- x77    N)__name__
__module____qualname__r'    r(   r&   r   r   (   s    8r(   r   c                    	 t        j                  |j                               }t        | t              r`|r>d|v r!|d   d   }dj                  d |D              }n|}t        || j                        t        t        |       | j                        |S # t        $ r$ |j	                  d       |j                         }Y w xY w)Nr   errorserror
c              3   &   K   | ]	  }|d      yw)zerror-messageNr,   ).0r/   s     r&   	<genexpr>z"handle_response.<locals>.<genexpr>J   s     'S5o(>'Ss   )code)r   loadsread
ValueErrorseek
isinstancer   r   r   r4   r   )r$   r%   r.   
error_texts       r&   r    r    ?   s    -

=#5#5#78
 (I&=(&x09!YY'SF'ST
*
!*8==AAgh/hmmDD  -1%**,-s   #B *CC)
__future__r   r   r   type__metaclass__DOCUMENTATIONr   ansible.module_utils._textr   ansible.module_utils.connectionr   +ansible.module_utils.six.moves.urllib.errorr   Gansible_collections.ansible.netcommon.plugins.plugin_utils.httpapi_baser	   r   r   r    r,   r(   r&   <module>rC      sE   
 A @ $  . ; A _ ,8k 8.r(   