# Path: tsuru_autoscale/instance/client.py
# def host():
# def list(token):
# def get(name, token):
# def alarms_by_instance(instance, token):
# 
# Path: tsuru_autoscale/event/client.py
# def host():
# def list(alarm_name, token):


from django.shortcuts import render
from tsuru_autoscale.instance import client
from tsuru_autoscale.event import client as eclient



def list(request, app_name=None):
    token = request.session.get('tsuru_token').split(" ")[-1]
    instances = client.list(token).json()
    context = {
        "list": instances,
    }
    return render(request, "instance/list.html", context)


def get(request, name):
    token = request.session.get('tsuru_token').split(" ")[-1]
    instance = client.get(name, token).json()

# Path: tsuru_autoscale/instance/client.py
# def host():
# def list(token):
# def get(name, token):
# def alarms_by_instance(instance, token):
# 
# Path: tsuru_autoscale/event/client.py
# def host():
# def list(alarm_name, token):


# Path: tsuru_autoscale/instance/views.py
from django.shortcuts import render
from tsuru_autoscale.instance import client
from tsuru_autoscale.event import client as eclient




def list(request, app_name=None):
    token = request.session.get('tsuru_token').split(" ")[-1]
    instances = client.list(token).json()
    context = {
        "list": instances,
    }
    return render(request, "instance/list.html", context)


def get(request, name):
    token = request.session.get('tsuru_token').split(" ")[-1]
    instance = client.get(name, token).json()

    alarms = client.alarms_by_instance(name, token).json() or []