# Path: pydomo/groups/GroupsModel.py
# class CreateGroupRequest(DomoObject):
#     accepted_attrs = [
#         'name',
#         'active',
#         'default',
#         'memberCount'
#     ]


from random import randint
from pydomo.groups import CreateGroupRequest


def groups(domo):
    '''Group Docs:
    https://developer.domo.com/docs/domo-apis/group-apis
    '''
    domo.logger.info("\n**** Domo API - Group Examples ****\n")
    groups = domo.groups

    # Build a Group
    group_request = CreateGroupRequest()
    group_request.name = 'Groupy Group {}'.format(randint(0, 10000))
    group_request.active = True
    group_request.default = False

    # Create a Group
    group = groups.create(group_request)
    domo.logger.info("Created Group '{}'".format(group['name']))

    # Get a Group
    group = groups.get(group['id'])
    domo.logger.info("Retrieved Group '{}'".format(group['name']))

    # List Groups
    group_list = groups.list(10, 0)
    domo.logger.info("Retrieved a list containing {} Group(s)".format(
                                                          len(group_list)))

    # Update a Group

# Path: pydomo/groups/GroupsModel.py
# class CreateGroupRequest(DomoObject):
#     accepted_attrs = [
#         'name',
#         'active',
#         'default',
#         'memberCount'
#     ]


# Path: examples/group.py
from random import randint
from pydomo.groups import CreateGroupRequest



def groups(domo):
    '''Group Docs:
    https://developer.domo.com/docs/domo-apis/group-apis
    '''
    domo.logger.info("\n**** Domo API - Group Examples ****\n")
    groups = domo.groups

    # Build a Group
    group_request = CreateGroupRequest()
    group_request.name = 'Groupy Group {}'.format(randint(0, 10000))
    group_request.active = True
    group_request.default = False

    # Create a Group
    group = groups.create(group_request)
    domo.logger.info("Created Group '{}'".format(group['name']))

    # Get a Group
    group = groups.get(group['id'])
    domo.logger.info("Retrieved Group '{}'".format(group['name']))

    # List Groups
    group_list = groups.list(10, 0)
    domo.logger.info("Retrieved a list containing {} Group(s)".format(
                                                          len(group_list)))

    # Update a Group

    group_update = CreateGroupRequest()