@ -32,6 +32,7 @@
import os
import os
from ansible . module_utils . basic import AnsibleModule , json , env_fallback
from ansible . module_utils . basic import AnsibleModule , json , env_fallback
from ansible . module_utils . urls import fetch_url
from ansible . module_utils . urls import fetch_url
from ansible . module_utils . six . moves . urllib . parse import urlencode
from ansible . module_utils . _text import to_native , to_bytes , to_text
from ansible . module_utils . _text import to_native , to_bytes , to_text
@ -249,9 +250,28 @@ class MerakiModule(object):
return template [ ' id ' ]
return template [ ' id ' ]
self . fail_json ( msg = ' No configuration template named {0} found ' . format ( name ) )
self . fail_json ( msg = ' No configuration template named {0} found ' . format ( name ) )
def construct_path ( self , action , function = None , org_id = None , net_id = None , org_name = None , custom = None ) :
def construct_params_list ( self , keys , aliases = None ) :
qs = { }
for key in keys :
if key in aliases :
qs [ aliases [ key ] ] = self . module . params [ key ]
else :
qs [ key ] = self . module . params [ key ]
return qs
def encode_url_params ( self , params ) :
""" Encodes key value pairs for URL """
return " ? {0} " . format ( urlencode ( params ) )
def construct_path ( self ,
action ,
function = None ,
org_id = None ,
net_id = None ,
org_name = None ,
custom = None ,
params = None ) :
""" Build a path from the URL catalog.
""" Build a path from the URL catalog.
Uses function property from class for catalog lookup .
Uses function property from class for catalog lookup .
"""
"""
built_path = None
built_path = None
@ -265,6 +285,8 @@ class MerakiModule(object):
built_path = built_path . format ( org_id = org_id , net_id = net_id , * * custom )
built_path = built_path . format ( org_id = org_id , net_id = net_id , * * custom )
else :
else :
built_path = built_path . format ( org_id = org_id , net_id = net_id )
built_path = built_path . format ( org_id = org_id , net_id = net_id )
if params :
built_path + = self . encode_url_params ( params )
return built_path
return built_path
def request ( self , path , method = None , payload = None ) :
def request ( self , path , method = None , payload = None ) :