# Path: ricloud/conf.py
# DEFAULT_CONF_NAME = "ricloud.ini"
# def get_config(config_name=DEFAULT_CONF_NAME):
# def get_user_root_config_path(config_name=DEFAULT_CONF_NAME):
# def get(setting_section, setting_name):
# def getint(setting_section, setting_name):
# def getboolean(setting_section, setting_name):
# 
# Path: ricloud/storage.py
# def download_result(url, to_filename=None):
# def download_result_from_gs(bucket_name, blob_name, to_filename=None):
# def download_result_from_s3(bucket_name, blob_name, to_filename=None):
# def download_result_from_local(blob_name, to_filename=None):
# 
# Path: ricloud/utils.py
# def log_debug(message, *args, **kwargs):
# def log_info(message, *args, **kwargs):
# def generate_timestamp():
# def _encode(data):
# def encode(data):
# def expanded_encode(data):
#     def default(self, data):
# def pretty_print(data):
# def encode_json(data, indent=None):
# def decode_json(data):
# def encode_b64(data):
# def decode_b64(data):
# def transform_csv_file_to_json(file_object):
# def join_url(base, url, allow_fragments=True):
# def get_url_path(url):
# def escape(string):
# def get_md5_hash(data, hex_encode=True):
# def get_path_extension(path):
# def get_directory_from_path(path):
# def ensure_directory_exists(directory):
# def ensure_path_exists(path):
# def get_filename(*args):
# class DataEncoder(json.JSONEncoder):
# class ExpandedDataEncoder(DataEncoder):
# 
# Path: ricloud/samples/utils.py
# def info(message):
#     click.secho(message, fg="yellow")
# 
# def warn(message):
#     click.secho(message, fg="red")
# 
# def success(message):
#     click.secho(message, fg="green")
# 
# def await_response(resource, timeout=60):
#     """Poll the API until processing resolves or the timeout is reached."""
#     timeout_time = time.time() + timeout
#     while resource.state in ("pending", "processing") and time.time() < timeout_time:
# 
#         time.sleep(1)
# 
#         resource.refresh()


import click
import ricloud
from ricloud import conf
from ricloud import storage
from ricloud import utils
from .utils import info, warn, success, await_response
    else:
        success("Subscription created, ID: {}".format(sub.id))

    return sub


def build_poll_payload(info_types, data_types, files):
    payload = {}

    if not (info_types or data_types or files):
        payload["data_types"] = ["ios_messages.messages"]

    if info_types:
        payload["info_types"] = info_types.split(",")

    if data_types:
        payload["data_types"] = data_types.split(",")

    if files:
        payload["files"] = files.split(",")

    return payload


def await_poll(poll):
    info("Awaiting completion of poll {} ...".format(poll.id))

    await_response(poll)

    if poll.state == "failed":

# Path: ricloud/conf.py
# DEFAULT_CONF_NAME = "ricloud.ini"
# def get_config(config_name=DEFAULT_CONF_NAME):
# def get_user_root_config_path(config_name=DEFAULT_CONF_NAME):
# def get(setting_section, setting_name):
# def getint(setting_section, setting_name):
# def getboolean(setting_section, setting_name):
# 
# Path: ricloud/storage.py
# def download_result(url, to_filename=None):
# def download_result_from_gs(bucket_name, blob_name, to_filename=None):
# def download_result_from_s3(bucket_name, blob_name, to_filename=None):
# def download_result_from_local(blob_name, to_filename=None):
# 
# Path: ricloud/utils.py
# def log_debug(message, *args, **kwargs):
# def log_info(message, *args, **kwargs):
# def generate_timestamp():
# def _encode(data):
# def encode(data):
# def expanded_encode(data):
#     def default(self, data):
# def pretty_print(data):
# def encode_json(data, indent=None):
# def decode_json(data):
# def encode_b64(data):
# def decode_b64(data):
# def transform_csv_file_to_json(file_object):
# def join_url(base, url, allow_fragments=True):
# def get_url_path(url):
# def escape(string):
# def get_md5_hash(data, hex_encode=True):
# def get_path_extension(path):
# def get_directory_from_path(path):
# def ensure_directory_exists(directory):
# def ensure_path_exists(path):
# def get_filename(*args):
# class DataEncoder(json.JSONEncoder):
# class ExpandedDataEncoder(DataEncoder):
# 
# Path: ricloud/samples/utils.py
# def info(message):
#     click.secho(message, fg="yellow")
# 
# def warn(message):
#     click.secho(message, fg="red")
# 
# def success(message):
#     click.secho(message, fg="green")
# 
# def await_response(resource, timeout=60):
#     """Poll the API until processing resolves or the timeout is reached."""
#     timeout_time = time.time() + timeout
#     while resource.state in ("pending", "processing") and time.time() < timeout_time:
# 
#         time.sleep(1)
# 
#         resource.refresh()


# Path: ricloud/samples/helpers.py
import click
import ricloud
from ricloud import conf
from ricloud import storage
from ricloud import utils
from .utils import info, warn, success, await_response

    else:
        success("Subscription created, ID: {}".format(sub.id))

    return sub


def build_poll_payload(info_types, data_types, files):
    payload = {}

    if not (info_types or data_types or files):
        payload["data_types"] = ["ios_messages.messages"]

    if info_types:
        payload["info_types"] = info_types.split(",")

    if data_types:
        payload["data_types"] = data_types.split(",")

    if files:
        payload["files"] = files.split(",")

    return payload


def await_poll(poll):
    info("Awaiting completion of poll {} ...".format(poll.id))

    await_response(poll)

    if poll.state == "failed":

        warn("Poll failed with error: `{}`".format(poll.error))