
    Vh6                         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 d dlmZm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%	  
---
module: meraki_snmp
short_description: Manage organizations in the Meraki cloud
description:
- Allows for management of SNMP settings for Meraki.
deprecated:
  removed_in: '3.0.0'
  why: Updated modules released with increased functionality
  alternative: cisco.meraki.networks_snmp
options:
    state:
        description:
        - Specifies whether SNMP information should be queried or modified.
        choices: ['query', 'present']
        default: present
        type: str
    v2c_enabled:
        description:
        - Specifies whether SNMPv2c is enabled.
        type: bool
    v3_enabled:
        description:
        - Specifies whether SNMPv3 is enabled.
        type: bool
    v3_auth_mode:
        description:
        - Sets authentication mode for SNMPv3.
        choices: ['MD5', 'SHA']
        type: str
    v3_auth_pass:
        description:
        - Authentication password for SNMPv3.
        - Must be at least 8 characters long.
        type: str
    v3_priv_mode:
        description:
        - Specifies privacy mode for SNMPv3.
        choices: ['DES', 'AES128']
        type: str
    v3_priv_pass:
        description:
        - Privacy password for SNMPv3.
        - Must be at least 8 characters long.
        type: str
    peer_ips:
        description:
        - List of IP addresses which can perform SNMP queries.
        type: list
        elements: str
    net_name:
        description:
        - Name of network.
        type: str
    net_id:
        description:
        - ID of network.
        type: str
    access:
        description:
        - Type of SNMP access.
        choices: [community, none, users]
        type: str
    community_string:
        description:
        - SNMP community string.
        - Only relevant if C(access) is set to C(community).
        type: str
    users:
        description:
        - Information about users with access to SNMP.
        - Only relevant if C(access) is set to C(users).
        type: list
        elements: dict
        suboptions:
            username:
                description: Username of user with access.
                type: str
            passphrase:
                description: Passphrase for user SNMP access.
                type: str
author:
- Kevin Breit (@kbreit)
extends_documentation_fragment: cisco.meraki.meraki
a  
- name: Query SNMP values
  meraki_snmp:
    auth_key: abc12345
    org_name: YourOrg
    state: query
  delegate_to: localhost

- name: Enable SNMPv2
  meraki_snmp:
    auth_key: abc12345
    org_name: YourOrg
    state: present
    v2c_enabled: true
  delegate_to: localhost

- name: Disable SNMPv2
  meraki_snmp:
    auth_key: abc12345
    org_name: YourOrg
    state: present
    v2c_enabled: false
  delegate_to: localhost

- name: Enable SNMPv3
  meraki_snmp:
    auth_key: abc12345
    org_name: YourOrg
    state: present
    v3_enabled: true
    v3_auth_mode: SHA
    v3_auth_pass: ansiblepass
    v3_priv_mode: AES128
    v3_priv_pass: ansiblepass
    peer_ips: 192.0.1.1;192.0.1.2
  delegate_to: localhost

- name: Set network access type to community string
  meraki_snmp:
    auth_key: abc1235
    org_name: YourOrg
    net_name: YourNet
    state: present
    access: community
    community_string: abc123
  delegate_to: localhost

- name: Set network access type to username
  meraki_snmp:
    auth_key: abc1235
    org_name: YourOrg
    net_name: YourNet
    state: present
    access: users
    users:
      - username: ansibleuser
        passphrase: ansiblepass
  delegate_to: localhost
a
  
data:
    description: Information about SNMP settings.
    type: complex
    returned: always
    contains:
        hostname:
            description: Hostname of SNMP server.
            returned: success and no network specified.
            type: str
            sample: n1.meraki.com
        peer_ips:
            description: Semi-colon delimited list of IPs which can poll SNMP information.
            returned: success and no network specified.
            type: str
            sample: 192.0.1.1
        port:
            description: Port number of SNMP.
            returned: success and no network specified.
            type: str
            sample: 16100
        v2c_enabled:
            description: Shows enabled state of SNMPv2c
            returned: success and no network specified.
            type: bool
            sample: true
        v3_enabled:
            description: Shows enabled state of SNMPv3
            returned: success and no network specified.
            type: bool
            sample: true
        v3_auth_mode:
            description: The SNMP version 3 authentication mode either MD5 or SHA.
            returned: success and no network specified.
            type: str
            sample: SHA
        v3_priv_mode:
            description: The SNMP version 3 privacy mode DES or AES128.
            returned: success and no network specified.
            type: str
            sample: AES128
        v2_community_string:
            description: Automatically generated community string for SNMPv2c.
            returned: When SNMPv2c is enabled and no network specified.
            type: str
            sample: o/8zd-JaSb
        v3_user:
            description: Automatically generated username for SNMPv3.
            returned: When SNMPv3c is enabled and no network specified.
            type: str
            sample: o/8zd-JaSb
        access:
            description: Type of SNMP access.
            type: str
            returned: success, when network specified
        community_string:
            description: SNMP community string. Only relevant if C(access) is set to C(community).
            type: str
            returned: success, when network specified
        users:
            description: Information about users with access to SNMP. Only relevant if C(access) is set to C(users).
            type: complex
            contains:
                username:
                    description: Username of user with access.
                    type: str
                    returned: success, when network specified
                passphrase:
                    description: Passphrase for user SNMP access.
                    type: str
                    returned: success, when network specified
)AnsibleModulejson)snake_dict_to_camel_dict)MerakiModulemeraki_argument_specc                 r    | j                  d|      }| j                  |d      }| j                  dk(  r|S y )Nget_allorg_idGETmethod   )construct_pathrequestr	   )merakir   pathrs       l/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/meraki/plugins/modules/meraki_snmp.pyget_snmpr      sG      6 :Dt# 	 	A }}     c                    t               }| j                  d   d| j                  d   i}| j                  d   du rt        | j                  d         dk  st        | j                  d         dk  r| j                  d	       | j                  d
   -| j                  d   | j                  d   | j                  d   | j                  d	       | j                  d   | j                  d
   j	                         | j                  d   | j                  d   j	                         | j                  d   d}| j                  d   (| j                  d   |d<   n| j                  d   du rddi}t        |      }| j                  d|      }t        | |      }g d}| j                  |||      r| j                  j                  du r]| j                  ||       |j                  |       || j                  d<   d| j                  d<    | j                  di | j                   | j                  |dt!        j"                  |            }| j$                  dk(  r#| j                  ||       d| j                  d<   |S y |S )Nv2c_enabled
v2cEnabled
v3_enabledTv3_auth_pass   v3_priv_passzFv3_auth_pass and v3_priv_pass must both be at least 8 characters long.msgv3_auth_modev3_priv_modezGv3_auth_mode, v3_auth_pass, v3_priv_mode, and v3_auth_pass are required)	v3Enabled
v3AuthMode
v3AuthPass
v3PrivMode
v3PrivPasspeer_ipspeerIpsFr+   creater   )r-   r/   hostnameportv2CommunityStringv3User)optional_ignoredatachangedPUTr   payloadr    )dictparamslen	fail_jsonupperr   r   r   is_update_requiredmodule
check_modegenerate_diffupdateresult	exit_jsonr   r   dumpsr	   )r   r   r<   full_comparer   snmpignored_parametersr   s           r   set_snmprN      sg   fG}}]#/}!= }}\"d*v}}^,-1S~9V5WZ[5[!ij==(0==(0==(0==(0!jk &l ;!'~!>!D!D!F!'~!>!'~!>!D!D!F!'~!>	 ==$0!'z!:GI	|	$	-&+G4L  & 9DFF#Dh  |EW X==##t+  |4KK $(FMM&!'+FMM)$F-v}}-NN4"'#'::g#6  8 ==C  q)'+FMM)$H  
 r   c                     t        t        d      t        dd            } t               }|j                  t        dddgd      t        d	      t        d	      t        dd
dg      t        dd      t        dddg      t        dd      t        dd d      t        dg d      t        dd      t        dd d|       t        d      t        d             t        |d      }t	        |d      }d|j
                  d<   ddi}ddi}ddi}ddi}|j                  d   j                  |       ||j                  d<   ||j                  d<   ||j                  d<   d }|j
                  d    s!|j
                  d!   s|j                  d"#       |j
                  d!   }	|	|j                  |j
                  d          }	|j
                  d$   }
|
B|j
                  d%   r3|j                  |	&      }|j                  |	|j
                  d%   |'      }
|j
                  d(   dk(  rV|
Td)|j
                  d)   i}|j
                  d*   |j
                  d*   |d+<   n!|j
                  d,   |j
                  d,   |d,<   |j
                  d(   dk(  rc|
t        ||	      |j                  d-<   n;|j                  d|
.      }|j                  |d/0      }|j                  d1k(  r||j                  d-<   n|j
                  d(   dk(  r|
t!        ||	      |j                  d-<   n|j                  d|
.      }|j                  |d/0      }|j#                  ||      r|j                  d|
.      }|j                  |d2t%        j&                  |      3      }|j                  d1k(  rF|d)   d4k(  ri |j                  d-<   n||j                  d-<   d|j                  d5<   n||j                  d-<    |j(                  d6i |j                   y )7Nstr)typeT)rQ   no_log)username
passphrasepresentquery)rQ   choicesdefaultboolSHAMD5)rQ   rW   DESAES128list)rQ   rX   elements)noner   usersr>   )rQ   rX   r_   options)stater!   r#   r)   r$   r*   r&   r0   accesscommunity_stringra   net_namenet_id)argument_specsupports_check_moderL   )functionallfollow_redirectsz/organizations/{org_id}/snmpz/networks/{net_id}/snmpr   query_net_allr2   
create_netorg_namer   zorg_name or org_id is requiredr'   rg   rf   r   )r8   rc   rd   re   communityStringra   r8   )rg   r   r   r   r:   r;   r`   r9   r=   )r>   r   rG   r   r   r?   url_catalogrA   
get_org_idget_nets
get_net_idr   rH   r   r   r	   rN   rC   r   rJ   rI   )user_arg_specrh   rD   r   
query_urlsquery_net_urlsupdate_urlsupdate_net_urlsr<   r   rg   netsr   responseoriginals                  r   mainr}   &  s    $E"2$(eD$AM )*MtG8LV_`%)v%6$(f$5&*u~&N&*d&C&*x?P&Q&*d&C"&FD5"Q $%9W X*.E$*G#Xef"&E"2 $% 0  & /3F &62F(-FMM$%89J78N9:K89O
y!((4*8F'#.Fx '6F|$G==$V]]8-D=>]]8$F~""6==#<=]]8$F~&--
3f-""66==+D4"P}}W*x!89G}}/0<-3]];M-N)*w'3#)==#9 }}W(>$,VV$<FMM&!(((HD~~d5~9H}}#(0f%	w	9	,>$,VV$<FMM&!(((HD~~d5~9H((7;,,\&,I!>>$udjjQXFY>Z==C')V302f-08f-/3FMM),(0f% F%v}}%r   __main__N)
__future__r   r   r   rQ   __metaclass__ANSIBLE_METADATADOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   r   0ansible.module_utils.common.dict_transformationsr   Kansible_collections.cisco.meraki.plugins.module_utils.network.meraki.merakir   r   r   rN   r}   __name__r=   r   r   <module>r      ss    A @ n Tl:xG
R ; U z*Z]&@ zF r   