# Path: website/utils.py
# def get_api_server_url(path):
#     """
#     Return the url for api server.
#     """
#     return "http://" + settings.API_SERVER + path
# 
# def get_url_of_monitor_iframe(type, namespace, pod_name):
#     """
#     Get the url of monitor iframe in user dashboard.
#     """
#     if type == "memory":
#         type_id = 1
#     elif type == "cpu":
#         type_id = 14
# 
#     items = pod_name.split('-')
#     container = '-'.join(items[0:-1])
#     url = 'http://{}/dashboard-solo/db/containers?panelId={}&fullscreen&\
# var-namespace={}&var-pod={}&var-container={}'.format(settings.GRAFANA_SERVER,
#     type_id, namespace, pod_name, container)
# 
#     return url


import json
import logging
import requests
from website.utils import (get_api_server_url, get_url_of_monitor_iframe)



logger = logging.getLogger('website')


class Communicator(object):
    """
    The Communicator with the backend api server.
    """
    client = None

    def __init__(self, cookies={}):
        self.client = requests.session()
        for name, value in cookies.items():
            self.client.cookies[name] = value

    def login(self, data):
        """
        Return cookies.
        """

# Path: website/utils.py
# def get_api_server_url(path):
#     """
#     Return the url for api server.
#     """
#     return "http://" + settings.API_SERVER + path
# 
# def get_url_of_monitor_iframe(type, namespace, pod_name):
#     """
#     Get the url of monitor iframe in user dashboard.
#     """
#     if type == "memory":
#         type_id = 1
#     elif type == "cpu":
#         type_id = 14
# 
#     items = pod_name.split('-')
#     container = '-'.join(items[0:-1])
#     url = 'http://{}/dashboard-solo/db/containers?panelId={}&fullscreen&\
# var-namespace={}&var-pod={}&var-container={}'.format(settings.GRAFANA_SERVER,
#     type_id, namespace, pod_name, container)
# 
#     return url


# Path: website/communicate.py
import json
import logging
import requests
from website.utils import (get_api_server_url, get_url_of_monitor_iframe)




logger = logging.getLogger('website')


class Communicator(object):
    """
    The Communicator with the backend api server.
    """
    client = None

    def __init__(self, cookies={}):
        self.client = requests.session()
        for name, value in cookies.items():
            self.client.cookies[name] = value

    def login(self, data):
        """
        Return cookies.
        """

        url = get_api_server_url('/api/auth/login/')