# Path: cloudkittydashboard/utils.py
# class TemplatizableDict(dict):
#     def __getattr__(self, key):
#     def __setattr__(self, key, val):


from collections import abc
from django.conf import settings
from horizon.utils.memoized import memoized  # noqa
from keystoneauth1.identity.v3 import Token
from cloudkittyclient import client as ck_client
from cloudkittydashboard import utils
        token=request.user.token.id,
        project_id=request.user.project_id,
        domain_id=request.user.domain_id,
    )

    adapter_options = {
        'region_name': request.user.services_region,
        'interface': interface,
    }

    return ck_client.Client(
        '1',
        auth=auth,
        cacert=cacert,
        insecure=insecure,
        adapter_options=adapter_options,
    )


def identify(what, name=False, key=None):
    if isinstance(what, abc.Iterable):
        for i in what:
            i['id'] = i.get(key or "%s_id" % i['key'])
            if name and not i.get('name'):
                i['name'] = i.get(key or "%s_id" % i['key'])
        what = [utils.TemplatizableDict(i) for i in what]
    else:
        what['id'] = what.get(key or "%s_id" % what['key'])
        if name and not i.get('name'):
            what['name'] = what.get(key or "%s_id" % what['key'])

# Path: cloudkittydashboard/utils.py
# class TemplatizableDict(dict):
#     def __getattr__(self, key):
#     def __setattr__(self, key, val):


# Path: cloudkittydashboard/api/cloudkitty.py
from collections import abc
from django.conf import settings
from horizon.utils.memoized import memoized  # noqa
from keystoneauth1.identity.v3 import Token
from cloudkittyclient import client as ck_client
from cloudkittydashboard import utils

        token=request.user.token.id,
        project_id=request.user.project_id,
        domain_id=request.user.domain_id,
    )

    adapter_options = {
        'region_name': request.user.services_region,
        'interface': interface,
    }

    return ck_client.Client(
        '1',
        auth=auth,
        cacert=cacert,
        insecure=insecure,
        adapter_options=adapter_options,
    )


def identify(what, name=False, key=None):
    if isinstance(what, abc.Iterable):
        for i in what:
            i['id'] = i.get(key or "%s_id" % i['key'])
            if name and not i.get('name'):
                i['name'] = i.get(key or "%s_id" % i['key'])
        what = [utils.TemplatizableDict(i) for i in what]
    else:
        what['id'] = what.get(key or "%s_id" % what['key'])
        if name and not i.get('name'):
            what['name'] = what.get(key or "%s_id" % what['key'])

        what = utils.TemplatizableDict(what)