# Buggy code
def get_resources_in_resource_group(cli_ctx, resource_group_name, resource_type=None):
    from azure.cli.core.commands.client_factory import get_mgmt_service_client

    rcf = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)
    filter_str = "resourceType eq '{}'".format(resource_type) if resource_type else None
    if cli_ctx.cloud.supported_api_version(
        ResourceType.MGMT_RESOURCE_RESOURCES, max_api="2016-09-01"
    ):
        return list(
            rcf.resource_groups.list_resources(resource_group_name, filter=filter_str)
        )
    return list(
        rcf.resources.list_by_resource_group(resource_group_name, filter=filter_str)
    )


# Traceback (AttributeError)
Traceback (most recent call last):
File "/Users/chrmarti/anaconda/envs/az-2.0.24-python3.5/lib/python3.5/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Users/chrmarti/anaconda/envs/az-2.0.24-python3.5/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/chrmarti/Development/repos/vscode-azurecli/service/azservice/__main__.py", line 338, in <module>
main()
File "/Users/chrmarti/Development/repos/vscode-azurecli/service/azservice/__main__.py", line 327, in main
response_data = get_completions(group_index, command_table, snippets, request['data'], True)
File "/Users/chrmarti/Development/repos/vscode-azurecli/service/azservice/__main__.py", line 114, in get_completions
return get_argument_value_completions(command_table, query, verbose)
File "/Users/chrmarti/Development/repos/vscode-azurecli/service/azservice/__main__.py", line 182, in get_argument_value_completions
list = get_argument_value_list(command_table, query, verbose) + \
File "/Users/chrmarti/Development/repos/vscode-azurecli/service/azservice/__main__.py", line 200, in get_argument_value_list
values = run_argument_value_completer(command, argument, query['arguments'])
File "/Users/chrmarti/Development/repos/vscode-azurecli/service/azservice/tooling2.py", line 117, in run_argument_value_completer
return argument.completer(prefix='', action=None, parsed_args=args)
File "/Users/chrmarti/anaconda/envs/az-2.0.24-python3.5/lib/python3.5/site-packages/azure/cli/core/decorators.py", line 36, in __call__
return self.func(cmd, prefix, namespace)
File "/Users/chrmarti/anaconda/envs/az-2.0.24-python3.5/lib/python3.5/site-packages/azure/cli/core/commands/parameters.py", line 91, in completer
return [r.name for r in get_resources_in_resource_group(cmd.cli_ctx, rg, resource_type=resource_type)]
File "/Users/chrmarti/anaconda/envs/az-2.0.24-python3.5/lib/python3.5/site-packages/azure/cli/core/commands/parameters.py", line 73, in get_resources_in_resource_group
if cli_ctx.cloud.supported_api_version(ResourceType.MGMT_RESOURCE_RESOURCES, max_api='2016-09-01'):
AttributeError: 'Cloud' object has no attribute 'supported_api_version'

# Fixed code
def get_resources_in_resource_group(cli_ctx, resource_group_name, resource_type=None):
    from azure.cli.core.commands.client_factory import get_mgmt_service_client
    from azure.cli.core.profiles import supported_api_version

    rcf = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)
    filter_str = "resourceType eq '{}'".format(resource_type) if resource_type else None
    if supported_api_version(
        cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, max_api="2016-09-01"
    ):
        return list(
            rcf.resource_groups.list_resources(resource_group_name, filter=filter_str)
        )
    return list(
        rcf.resources.list_by_resource_group(resource_group_name, filter=filter_str)
    )