
    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
mZmZ d d
lmZmZ d Zd Zd Zd Zd Zd Zedk(  r e        yy)    )absolute_importdivisionprint_functionz1.1
deprecated	community)metadata_versionstatussupported_bya  
author:
  - Kevin Breit (@kbreit)
deprecated:
  alternative: cisco.meraki.networks_webhooks_http_servers
  removed_in: 3.0.0
  why: Updated modules released with increased functionality
description:
  - Configure and query information about webhooks within the Meraki cloud.
extends_documentation_fragment: cisco.meraki.meraki
module: meraki_webhook
notes:
  - Some of the options are likely only used for developers within Meraki.
options:
  name:
    description:
      - Name of webhook.
    type: str
  net_id:
    description:
      - ID of network which configuration is applied to.
    type: str
  net_name:
    aliases:
      - network
    description:
      - Name of network which configuration is applied to.
    type: str
  payload_template_id:
    description:
      - The ID of the payload template. Overrides payload_template_name if passed
        too.
    type: str
  payload_template_name:
    description:
      - The name of the payload template
    type: str
  shared_secret:
    description:
      - Secret password to use when accessing webhook.
    type: str
  state:
    choices:
      - absent
      - present
      - query
    default: query
    description:
      - Specifies whether object should be queried, created/modified, or removed.
    type: str
  test:
    choices:
      - test
    description:
      - Indicates whether to test or query status.
    type: str
  test_id:
    description:
      - ID of webhook test query.
    type: str
  url:
    description:
      - URL to access when calling webhook.
    type: str
  webhook_id:
    description:
      - Unique ID of webhook.
    type: str
short_description: Manage webhooks configured in the Meraki cloud
a  
- name: Create webhook
  meraki_webhook:
    auth_key: abc123
    state: present
    org_name: YourOrg
    net_name: YourNet
    name: Test_Hook
    url: https://webhook.url/
    shared_secret: shhhdonttellanyone
    payload_template_name: Slack (included)
  delegate_to: localhost
- name: Query one webhook
  meraki_webhook:
    auth_key: abc123
    state: query
    org_name: YourOrg
    net_name: YourNet
    name: Test_Hook
  delegate_to: localhost
- name: Query all webhooks
  meraki_webhook:
    auth_key: abc123
    state: query
    org_name: YourOrg
    net_name: YourNet
  delegate_to: localhost
- name: Delete webhook
  meraki_webhook:
    auth_key: abc123
    state: absent
    org_name: YourOrg
    net_name: YourNet
    name: Test_Hook
  delegate_to: localhost
- name: Test webhook
  meraki_webhook:
    auth_key: abc123
    state: present
    org_name: YourOrg
    net_name: YourNet
    test: test
    url: https://webhook.url/abc123
  delegate_to: localhost
- name: Get webhook status
  meraki_webhook:
    auth_key: abc123
    state: present
    org_name: YourOrg
    net_name: YourNet
    test: status
    test_id: abc123531234
  delegate_to: localhost
a<  
data:
    description: List of administrators.
    returned: success
    type: complex
    contains:
        id:
          description: Unique ID of webhook.
          returned: success
          type: str
          sample: aHR0cHM6Ly93ZWJob22LnvpdGUvOGViNWI3NmYtYjE2Ny00Y2I4LTlmYzQtND32Mj3F5NzIaMjQ0
        name:
          description: Descriptive name of webhook.
          returned: success
          type: str
          sample: Test_Hook
        networkId:
          description: ID of network containing webhook object.
          returned: success
          type: str
          sample: N_12345
        shared_secret:
          description: Password for webhook.
          returned: success
          type: str
          sample: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
        url:
          description: URL of webhook endpoint.
          returned: success
          type: str
          sample: https://webhook.url/abc123
        status:
          description: Status of webhook test.
          returned: success, when testing webhook
          type: str
          sample: enqueued
        payloadTemplate:
          description: The payload template used when posting data to the HTTP server.
          returned: success
          type: str
          sample:
            payloadTemplateId: wpt_00001
            name: Meraki (included)
)AnsibleModulejson)MerakiModulemeraki_argument_specc                 0    |D ]  }| |d   k(  s|d   c S  y )Nnameid )r   webhookswebhooks      o/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/meraki/plugins/modules/meraki_webhook.pyget_webhook_idr      s,     !76?"4= !     c                 r    | j                  d|      }| j                  |d      }| j                  dk(  r|S y )Nget_allnet_idGETmethod   )construct_pathrequestr	   merakir   pathresponses       r   get_all_webhooksr&      s?      6 :D~~d5~1H}} r   c                     	 d| j                   d   d   d<   	 | j                   d   D ]  }d|d<   	 	 	 d| j                   d   d<   y # t        $ r Y :w xY w# t        t        f$ r Y 4w xY w# t        t        f$ r Y y w xY w)N#VALUE_SPECIFIED_IN_NO_LOG_PARAMETERdiffbeforeshared_secretdata)resultKeyError	TypeError)r#   is     r   sanitize_no_log_valuesr1      s     2 	fh'	

v& 	6A 6 	61Vfo.   i   i  s3   A A A* 	AAA'&A'*A<;A<c                     | j                  d|      }| j                  |d      }| j                  dk7  r| j                  d       |S )Nget_payload_templatesr   r   r   z'Unable to get webhook payload templatesmsg)r    r!   r	   	fail_jsonr"   s       r   get_webhook_payload_templatesr7      sK      !8 HD~~dE*H}}FGOr   c                 r    |D ]  }|d   |k(  s|d   c S  | j                  dj                  |             y )Nr   payloadTemplateIdz+No payload template found with the name {0}r4   )r6   format)r#   	templatesr   templates       r   get_webhook_payload_template_idr=      sI     1Ft#/001 FMMdSTr   c                     t               } | j                  t        dg dd      t        ddg      t        d      t        d      t        d      t        dd	      t        d      t        dd
g      t        d      t        d      t        d             t        | d      }t	        |d      }d|j
                  d<   ddi}ddi}ddi}ddi}ddi}ddi}ddi}	ddi}
|j                  d   j                  |       |j                  d   j                  |       ||j                  d<   ||j                  d<   ||j                  d<   ||j                  d
<   |	|j                  d<   |
|j                  d<   |j
                  d   }||j                  |j
                  d         }|j
                  d    }|2|j                  |!      }|j                  |j
                  d"   |#      }t        ||      }|j
                  d$   }|*|j
                  d%   t        |||j
                  d%   &      }|j
                  d'   }d }|4|j
                  d(   r%t        ||      }t        |j
                  d(   |      }|j
                  d)   d*k(  rX|j
                  d
   I|j
                  d(   |j
                  d+   d,}|j
                  d-   |j
                  d-   |d.<   |d/|i|d0<   |j
                  d)   dk(  rn|q|j                  d|d1|i2      }|j                  |d34      }|j                   d5k(  r||j"                  d6<   t%        |        |j&                  dEi |j"                   n|j
                  d7   ~|j                  d|d8|j
                  d7   i2      }|j                  |d34      }|j                   d5k(  r||j"                  d6<   t%        |        |j&                  dEi |j"                   nS|j                  d|9      }|j                  |d34      }|j                   d5k(  r||j"                  d6<   t%        |        |j&                  dEi |j"                   n|j
                  d)   d*k(  r|j
                  d
   d
k(  rd+|j
                  d+   i}|j                  d
|9      }|j                  |d:t)        j*                  |      ;      }|j                   d<k(  r+||j"                  d6<    |j&                  dEi |j"                   ||j,                  du rL|j"                  d6<   ||j"                  d6   d=<   d|j"                  d><    |j&                  dEi |j"                   |j                  d|9      }|j                  |d:t)        j*                        ;      }|j                   d<k(  r||j"                  d6<   d|j"                  d><   nu|j                  d|d1|i2      }|j                  |d34      }|j/                  |      r|j,                  du rh|j1                  ||       t%        |       |j                  |       ||j"                  d6<   d|j"                  d><    |j&                  dEi |j"                   |j                  d|d1|i2      }|j                  |d?t)        j*                  |      ;      }|j                   d5k(  rv|j/                  ||      r|j1                  ||       t%        |       ||j"                  d6<   d|j"                  d><   n'||j"                  d6<   n|j
                  d)   d@k(  r|W|t        ||      }t        |j
                  d(   |      }|.|j3                  dAj5                  |j
                  d(         B       |r|j6                  j,                  du r:d |j"                  d6<   d|j"                  d><    |j&                  dEi |j"                   |j                  d|d1|i2      }|j                  |dC4      }|j                   dDk(  r||j"                  d6<   d|j"                  d><    |j&                  dEi |j"                   y )FNstr)absentpresentqueryrB   )typechoicesdefaultnetwork)rC   aliases)rC   T)rC   no_logtest)rC   rD   )statenet_namer   r   urlr+   
webhook_idrI   test_idpayload_template_namepayload_template_id)argument_specsupports_check_moder   )functionallfollow_redirectsz'/networks/{net_id}/webhooks/httpServersz0/networks/{net_id}/webhooks/httpServers/{hookid}z(/networks/{net_id}/webhooks/webhookTestsz1/networks/{net_id}/webhooks/webhookTests/{testid}z,/networks/{net_id}/webhooks/payloadTemplatesr   get_onecreateupdatedeletetest_statusr3   org_idorg_namer   )r[   rK   )rK   r,   rP   rO   )r   rM   r   rJ   rA   rL   )r   rL   r+   sharedSecretr9   payloadTemplatehookid)r   customr   r   r   r,   rN   testidr   POST)r   payload   	networkIdchangedPUTr@   z%There is no webhook with the name {0}r4   DELETE   r   )r   rX   dictr   r   paramsurl_catalog
get_org_idget_nets
get_net_idr7   r=   r&   r   r    r!   r	   r-   r1   	exit_jsonr   dumps
check_modeis_update_requiredgenerate_diffr6   r:   module)rQ   ru   r#   	query_urlquery_one_url
create_url
update_url
delete_urltest_urltest_status_urlquery_payload_templatesr[   r   netsr;   rP   rM   r   rc   r$   r%   originals                         r   mainr      sZ    )*M'EwW59+6ued3U#uvh/% ". e,  $ # F &:6F(-FMM$%FGI!STMGHJPQJPQJFGH!#VWOB y!((3
y!((7#-Fx #-Fx #-Fx !)Fv(7F}%2IF./]]8$F~""6==#<=]]8$F~f-""FMM*,ED"Q-ff=I --(=>#MM12>=IFMM2I$J
 |,JHfmmF3#FF3#FMM&$98D
}}W*v}}V/D/LMM&)=='
 ==)5&,mmO&DGN#**=?R)SG%&}}W(!((&(J1G ) D ~~d5~9H}}#(0f%&v.   16==1]]9%1(( &--	":; ) D
 ~~d5~9H}}#(0f%&v.   16==1((6(BD~~d5~9H}}#(0f%&v.   16==1	w	9	,== F*fmmE23G(((?D~~d64::gCV~WH}}#(0f%   16==1  D((/f%5;f%k2+/i(   16==1((&(AD~~d64::gCV~WH}}#(0f%+/i(((&(J1G ) D ~~d5~9H((7;$$,((7;*62OOG,,4FMM&)/3FMM),$F$$5v}}5,,VXz4J -  ">>

70C *  ==C'008D,,Xx@*62,4FMM&)/3FMM),(0f%	w	8	++FF;'f(=xHJ!  ?FFf- ! 
 }}''4/(,f%+/i(   16==1((:0F ) D ~~d8~<H}}#(0f%+/i( F%v}}%r   __main__N)
__future__r   r   r   rC   __metaclass__ANSIBLE_METADATADOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   r   Kansible_collections.cisco.meraki.plugins.module_utils.network.meraki.merakir   r   r   r&   r1   r7   r=   r   __name__r   r   r   <module>r      s    A @ n EN5n+
Z ;(U{&| zF r   