# Buggy code
def list_input_endpoints(kwargs=None, conn=None, call=None):
    """
    .. versionadded:: 2015.8.0

    List input endpoints associated with the deployment

    CLI Example:

    .. code-block:: bash

        salt-cloud -f list_input_endpoints my-azure service=myservice deployment=mydeployment
    """
    if call != "function":
        raise SaltCloudSystemExit(
            "The list_input_endpoints function must be called with -f or --function."
        )

    if kwargs is None:
        kwargs = {}

    if "service" not in kwargs:
        raise SaltCloudSystemExit('A service name must be specified as "service"')

    if "deployment" not in kwargs:
        raise SaltCloudSystemExit('A deployment name must be specified as "deployment"')

    path = "services/hostedservices/{0}/deployments/{1}".format(
        kwargs["service"],
        kwargs["deployment"],
    )

    data = query(path)
    if data is None:
        raise SaltCloudSystemExit(
            "There was an error listing endpoints with the {0} service on the {1} deployment.".format(
                kwargs["service"], kwargs["deployment"]
            )
        )

    ret = {}
    for item in data:
        if "Role" not in item:
            continue
        input_endpoint = item["Role"]["ConfigurationSets"]["ConfigurationSet"][
            "InputEndpoints"
        ]["InputEndpoint"]
        if not isinstance(input_endpoint, list):
            input_endpoint = [input_endpoint]
        for endpoint in input_endpoint:
            ret[endpoint["Name"]] = endpoint
    return ret


# Traceback (TypeError)
[ERROR   ] There was an error running the function: list indices must be integers, not str
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/cloud/cli.py", line 274, in run
self.function_provider, self.function_name, kwargs
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1598, in do_function
call='function', kwargs=kwargs
File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/msazure.py", line 2249, in delete_input_endpoint
activity='delete',
File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/msazure.py", line 2146, in update_input_endpoint
old_endpoints = list_input_endpoints(kwargs, call='function')
File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/msazure.py", line 2053, in list_input_endpoints
input_endpoint = item['Role']['ConfigurationSets']['ConfigurationSet']['InputEndpoints']['InputEndpoint']
TypeError: list indices must be integers, not str

# Fixed code
def list_input_endpoints(kwargs=None, conn=None, call=None):
    """
    .. versionadded:: 2015.8.0

    List input endpoints associated with the deployment

    CLI Example:

    .. code-block:: bash

        salt-cloud -f list_input_endpoints my-azure service=myservice deployment=mydeployment
    """
    if call != "function":
        raise SaltCloudSystemExit(
            "The list_input_endpoints function must be called with -f or --function."
        )

    if kwargs is None:
        kwargs = {}

    if "service" not in kwargs:
        raise SaltCloudSystemExit('A service name must be specified as "service"')

    if "deployment" not in kwargs:
        raise SaltCloudSystemExit('A deployment name must be specified as "deployment"')

    path = "services/hostedservices/{0}/deployments/{1}".format(
        kwargs["service"],
        kwargs["deployment"],
    )

    data = query(path)
    if data is None:
        raise SaltCloudSystemExit(
            "There was an error listing endpoints with the {0} service on the {1} deployment.".format(
                kwargs["service"], kwargs["deployment"]
            )
        )

    ret = {}
    for item in data:
        if "Role" not in item:
            continue
        for role in item["Role"]:
            input_endpoint = (
                role["ConfigurationSets"]["ConfigurationSet"]
                .get("InputEndpoints", {})
                .get("InputEndpoint")
            )
            if not input_endpoint:
                continue
            if not isinstance(input_endpoint, list):
                input_endpoint = [input_endpoint]
            for endpoint in input_endpoint:
                ret[endpoint["Name"]] = endpoint
    return ret