Ensure thing type exists.

    .. versionadded:: 2016.11.0

    name
        The name of the state definition

    thingTypeName
        Name of the thing type

    thingTypeDescription
        Description of the thing type

    searchableAttributesList
        List of string attributes that are searchable for
        the thing type

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used

    profile
        A dict with region, key, keyid, or a pillar key (string) that
        contains a dict with region, key, and keyid

def thing_type_present(name, thingTypeName, thingTypeDescription,
    searchableAttributesList,
    region=None, key=None, keyid=None, profile=None):
    '''
    Ensure thing type exists.

    .. versionadded:: 2016.11.0

    name
        The name of the state definition

    thingTypeName
        Name of the thing type

    thingTypeDescription
        Description of the thing type

    searchableAttributesList
        List of string attributes that are searchable for
        the thing type

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used

    profile
        A dict with region, key, keyid, or a pillar key (string) that
        contains a dict with region, key, and keyid

    '''
    ret = {
        'name': thingTypeName,
        'result': True,
        'comment': '',
        'changes': {}
    }

    r = __salt__['boto_iot.thing_type_exists'](
            thingTypeName=thingTypeName,
            region=region, key=key, keyid=keyid, profile=profile
    )

    if 'error' in r:
        ret['result'] = False
        ret['comment'] = 'Failed to create thing type: {0}.'.format(r['error']['message'])
        return ret

    if r.get('exists'):
        ret['result'] = True
        ret['comment'] = 'Thing type with given name {0} already exists'.format(thingTypeName)
        return ret

    if __opts__['test']:
        ret['comment'] = 'Thing type {0} is set to be created.'.format(thingTypeName)
        ret['result'] = None
        return ret

    r = __salt__['boto_iot.create_thing_type'](
            thingTypeName=thingTypeName,
            thingTypeDescription=thingTypeDescription,
            searchableAttributesList=searchableAttributesList,
            region=region, key=key, keyid=keyid, profile=profile
    )

    if not r.get('created'):
        ret['result'] = False
        ret['comment'] = 'Failed to create thing type: {0}.'.format(r['error']['message'])
        return ret

    _describe = __salt__['boto_iot.describe_thing_type'](
        thingTypeName=thingTypeName,
        region=region, key=key, keyid=keyid, profile=profile
    )
    ret['changes']['old'] = {'thing_type': None}
    ret['changes']['new'] = _describe
    ret['comment'] = 'Thing Type {0} created.'.format(thingTypeName)
    return ret