'create( self, trans, payload, **kwd )
* POST /api/repositories:
Creates a new repository.
Only ``name`` and ``synopsis`` parameters are required.
:param payload: dictionary structure containing::
\'name\':                  new repo\'s name (required)
\'synopsis\':              new repo\'s synopsis (required)
\'description\':           new repo\'s description (optional)
\'remote_repository_url\': new repo\'s remote repo (optional)
\'homepage_url\':          new repo\'s homepage url (optional)
\'category_ids[]\':        list of existing encoded TS category ids
the new repo should be associated with (optional)
\'type\':                  new repo\'s type, defaults to ``unrestricted`` (optional)
:type payload: dict
:returns:   detailed repository information
:rtype:     dict
:raises: RequestParameterMissingException, RequestParameterInvalidException'

@expose_api
def create(self, trans, **kwd):

    payload = kwd.get('payload', None)
    if (not payload):
        raise RequestParameterMissingException('You    did    not    specify    any    payload.')
    name = payload.get('name', None)
    if (not name):
        raise RequestParameterMissingException("Missing    required    parameter    'name'.")
    synopsis = payload.get('synopsis', None)
    if (not synopsis):
        raise RequestParameterMissingException("Missing    required    parameter    'synopsis'.")
    description = payload.get('description', '')
    remote_repository_url = payload.get('remote_repository_url', '')
    homepage_url = payload.get('homepage_url', '')
    category_ids = util.listify(payload.get('category_ids[]', ''))
    repo_type = payload.get('type', rt_util.UNRESTRICTED)
    if (repo_type not in rt_util.types):
        raise RequestParameterInvalidException('This    repository    type    is    not    valid')
    invalid_message = repository_util.validate_repository_name(self.app, name, trans.user)
    if invalid_message:
        raise RequestParameterInvalidException(invalid_message)
    (repo, message) = repository_util.create_repository(app=self.app, name=name, type=repo_type, description=synopsis, long_description=description, user_id=trans.user.id, category_ids=category_ids, remote_repository_url=remote_repository_url, homepage_url=homepage_url)
    repository_dict = repo.to_dict(view='element', value_mapper=self.__get_value_mapper(trans))
    repository_dict['category_ids'] = [trans.security.encode_id(x.category.id) for x in repo.categories]
    return repository_dict
