# Path: pydomo/datasets/DataSetModel.py
# class Column(DomoObject):
#     accepted_attrs = [
#         'type',
#         'name'
#     ]
# 
#     def __init__(self, column_type, name):
#         super().__init__()
#         self.type = column_type
#         self.name = name
# 
# class ColumnType:
#     STRING = 'STRING'
#     DECIMAL = 'DECIMAL'
#     LONG = 'LONG'
#     DOUBLE = 'DOUBLE'
#     DATE = 'DATE'
#     DATETIME = 'DATETIME'
# 
# class DataSetRequest(DomoObject):
#     accepted_attrs = [
#         'name',
#         'description',
#         'schema'
#     ]
# 
# class Policy(DomoObject):
#     accepted_attrs = [
#         'id',
#         'type',
#         'name',
#         'filters',
#         'users',
#         'virtualUsers',
#         'groups'
#     ]
# 
# class Schema(DomoObject):
#     accepted_attrs = [
#         'columns'
#     ]
#     def __init__(self, columns):
#         self.columns = columns
# 
# Path: pydomo/datasets/DataSetModel.py
# class FilterOperator:
#     EQUALS = 'EQUALS'
#     LIKE = 'LIKE'
#     GREATER_THAN = 'GREATER_THAN'
#     LESS_THAN = 'LESS_THAN'
#     GREATER_THAN_EQUAL = 'GREATER_THAN_EQUAL'
#     LESS_THAN_EQUAL = 'LESS_THAN_EQUAL'
#     BETWEEN = 'BETWEEN'
#     BEGINS_WITH = 'BEGINS_WITH'
#     ENDS_WITH = 'ENDS_WITH'
#     CONTAINS = 'CONTAINS'
# 
# class PolicyType:
#     USER = 'user'
#     SYSTEM = 'system'
# 
# class PolicyFilter(DomoObject):
#     accepted_attrs = [
#         'column',
#         'values',
#         'operator',
#         'not'
#     ]
# 
# class Sorting:
#     CARD_COUNT = 'cardCount'
#     DEFAULT = None
#     NAME = 'name'
#     STATUS = 'errorState'
#     UPDATED = 'lastUpdated'


from pydomo.datasets import DataSetRequest, Schema, Column, ColumnType, Policy
from pydomo.datasets import PolicyFilter, FilterOperator, PolicyType, Sorting


def datasets(domo):
    '''DataSets are useful for data sources that only require
    occasional replacement. See the docs at
    https://developer.domo.com/docs/data-apis/data
    '''
    domo.logger.info("\n**** Domo API - DataSet Examples ****\n")
    datasets = domo.datasets

    # Define a DataSet Schema
    dsr = DataSetRequest()
    dsr.name = 'Leonhard Euler Party'
    dsr.description = 'Mathematician Guest List'
    dsr.schema = Schema([Column(ColumnType.STRING, 'Friend')])

    # Create a DataSet with the given Schema
    dataset = datasets.create(dsr)
    domo.logger.info("Created DataSet " + dataset['id'])

    # Get a DataSets's metadata
    retrieved_dataset = datasets.get(dataset['id'])
    domo.logger.info("Retrieved DataSet " + retrieved_dataset['id'])

    # List DataSets
    dataset_list = list(datasets.list(sort=Sorting.NAME))
    domo.logger.info("Retrieved a list containing {} DataSet(s)".format(
                                                        len(dataset_list)))

    # Update a DataSets's metadata

# Path: pydomo/datasets/DataSetModel.py
# class Column(DomoObject):
#     accepted_attrs = [
#         'type',
#         'name'
#     ]
# 
#     def __init__(self, column_type, name):
#         super().__init__()
#         self.type = column_type
#         self.name = name
# 
# class ColumnType:
#     STRING = 'STRING'
#     DECIMAL = 'DECIMAL'
#     LONG = 'LONG'
#     DOUBLE = 'DOUBLE'
#     DATE = 'DATE'
#     DATETIME = 'DATETIME'
# 
# class DataSetRequest(DomoObject):
#     accepted_attrs = [
#         'name',
#         'description',
#         'schema'
#     ]
# 
# class Policy(DomoObject):
#     accepted_attrs = [
#         'id',
#         'type',
#         'name',
#         'filters',
#         'users',
#         'virtualUsers',
#         'groups'
#     ]
# 
# class Schema(DomoObject):
#     accepted_attrs = [
#         'columns'
#     ]
#     def __init__(self, columns):
#         self.columns = columns
# 
# Path: pydomo/datasets/DataSetModel.py
# class FilterOperator:
#     EQUALS = 'EQUALS'
#     LIKE = 'LIKE'
#     GREATER_THAN = 'GREATER_THAN'
#     LESS_THAN = 'LESS_THAN'
#     GREATER_THAN_EQUAL = 'GREATER_THAN_EQUAL'
#     LESS_THAN_EQUAL = 'LESS_THAN_EQUAL'
#     BETWEEN = 'BETWEEN'
#     BEGINS_WITH = 'BEGINS_WITH'
#     ENDS_WITH = 'ENDS_WITH'
#     CONTAINS = 'CONTAINS'
# 
# class PolicyType:
#     USER = 'user'
#     SYSTEM = 'system'
# 
# class PolicyFilter(DomoObject):
#     accepted_attrs = [
#         'column',
#         'values',
#         'operator',
#         'not'
#     ]
# 
# class Sorting:
#     CARD_COUNT = 'cardCount'
#     DEFAULT = None
#     NAME = 'name'
#     STATUS = 'errorState'
#     UPDATED = 'lastUpdated'


# Path: examples/dataset.py
from pydomo.datasets import DataSetRequest, Schema, Column, ColumnType, Policy
from pydomo.datasets import PolicyFilter, FilterOperator, PolicyType, Sorting



def datasets(domo):
    '''DataSets are useful for data sources that only require
    occasional replacement. See the docs at
    https://developer.domo.com/docs/data-apis/data
    '''
    domo.logger.info("\n**** Domo API - DataSet Examples ****\n")
    datasets = domo.datasets

    # Define a DataSet Schema
    dsr = DataSetRequest()
    dsr.name = 'Leonhard Euler Party'
    dsr.description = 'Mathematician Guest List'
    dsr.schema = Schema([Column(ColumnType.STRING, 'Friend')])

    # Create a DataSet with the given Schema
    dataset = datasets.create(dsr)
    domo.logger.info("Created DataSet " + dataset['id'])

    # Get a DataSets's metadata
    retrieved_dataset = datasets.get(dataset['id'])
    domo.logger.info("Retrieved DataSet " + retrieved_dataset['id'])

    # List DataSets
    dataset_list = list(datasets.list(sort=Sorting.NAME))
    domo.logger.info("Retrieved a list containing {} DataSet(s)".format(
                                                        len(dataset_list)))

    # Update a DataSets's metadata

    update = DataSetRequest()