# 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)
        return False

    def download_from_volume(self, project_id, volume_id):
        """
        Download data from volume with id volume_id.
        """
        url = get_api_server_url('/api/projects/{}/volumes/{}/download/'
            .format(project_id, volume_id))
        response = self.client.get(url)
        return response

    def clear_volume(self, project_id, volume_id):
        """
        Clear data of volume with id volume_id.
        """
        url = get_api_server_url('/api/projects/{}/volumes/{}/clear/'
            .format(project_id, volume_id))
        response = self.client.get(url)
        if response.status_code == 200:
            return True
        else:
            return False

    def get_container_monitor_image(self, type, namespace, pod_name):
        """
        Get container monitor image.

        Params:
        type: 1 is mem, 14 is cpu.
        """

# 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)

        return False

    def download_from_volume(self, project_id, volume_id):
        """
        Download data from volume with id volume_id.
        """
        url = get_api_server_url('/api/projects/{}/volumes/{}/download/'
            .format(project_id, volume_id))
        response = self.client.get(url)
        return response

    def clear_volume(self, project_id, volume_id):
        """
        Clear data of volume with id volume_id.
        """
        url = get_api_server_url('/api/projects/{}/volumes/{}/clear/'
            .format(project_id, volume_id))
        response = self.client.get(url)
        if response.status_code == 200:
            return True
        else:
            return False

    def get_container_monitor_image(self, type, namespace, pod_name):
        """
        Get container monitor image.

        Params:
        type: 1 is mem, 14 is cpu.
        """

        url = get_url_of_monitor_iframe(type, namespace, pod_name)