How to use the meraki.api_helper.APIHelper.serialize_array function in meraki

To help you get started, we’ve selected a few meraki examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github meraki / meraki-python-sdk / meraki / api_helper.py View on Github external
if value is not None:
                if isinstance(value, list):
                    value = [element for element in value if element]
                    if array_serialization is "csv":
                        url += "{0}{1}={2}".format(seperator, key,
                            ",".join(quote(str(x), safe='') for x in value))
                    elif array_serialization is "psv":
                        url += "{0}{1}={2}".format(seperator, key,
                            "|".join(quote(str(x), safe='') for x in value))
                    elif array_serialization is "tsv":
                        url += "{0}{1}={2}".format(seperator, key,
                            "\t".join(quote(str(x), safe='') for x in value))
                    else:
                        url += "{0}{1}".format(seperator,
                            "&".join(("{0}={1}".format(k, quote(str(v), safe='')))
                                for k, v in APIHelper.serialize_array(key, value, array_serialization)))
                else:
                    url += "{0}{1}={2}".format(seperator, key, quote(str(value), safe=''))

        return url
github meraki / meraki-python-sdk / meraki / api_helper.py View on Github external
array_serialization (string): The format of array parameter serialization.

        Returns:
            dict: A dictionary of form encoded properties of the model.

        """
        retval = []

        # If we received an object, resolve it's field names.
        if hasattr(obj, "_names"):
            obj = APIHelper.to_dictionary(obj)

        if obj is None:
            return []
        elif isinstance(obj, list):
            for element in APIHelper.serialize_array(instance_name, obj, array_serialization):
                retval += APIHelper.form_encode(element[1], element[0], array_serialization)
        elif isinstance(obj, dict):
            for item in obj:
                retval += APIHelper.form_encode(obj[item], instance_name + "[" + item + "]", array_serialization)
        else:
            retval.append((instance_name, obj))

        return retval