'Creates a new group type.'

@wsgi.Controller.api_version('3.11')
@wsgi.response(http_client.ACCEPTED)
def create(self, req, body):

    context = req.environ['cinder.context']
    self._check_policy(context)
    self.assert_valid_body(body, 'group_type')
    grp_type = body['group_type']
    name = grp_type.get('name', None)
    description = grp_type.get('description')
    specs = grp_type.get('group_specs', {})
    is_public = utils.get_bool_param('is_public', grp_type, True)
    if ((name is None) or (len(name.strip()) == 0)):
        msg = _('Group    type    name    can    not    be    empty.')
        raise webob.exc.HTTPBadRequest(explanation=msg)
    utils.check_string_length(name, 'Type    name', min_length=1, max_length=255)
    if (description is not None):
        utils.check_string_length(description, 'Type    description', min_length=0, max_length=255)
    try:
        group_types.create(context, name, specs, is_public, description=description)
        grp_type = group_types.get_group_type_by_name(context, name)
        req.cache_resource(grp_type, name='group_types')
        self._notify_group_type_info(context, 'group_type.create', grp_type)
    except exception.GroupTypeExists as err:
        self._notify_group_type_error(context, 'group_type.create', err, group_type=grp_type)
        raise webob.exc.HTTPConflict(explanation=six.text_type(err))
    except exception.GroupTypeNotFoundByName as err:
        self._notify_group_type_error(context, 'group_type.create', err, name=name)
        raise webob.exc.HTTPNotFound(explanation=err.msg)
    return self._view_builder.show(req, grp_type)
