Create a new :class:`Role` owned by this :class:`Subject`
18669
def create_role(self, name):
        ''''''
        models = self.session.router
        return models.role.new(name=name, owner=self)
1301441
public static function create(
        $subject = null,
        $body = null,
        $priority = null,
        $type = null,
        $channel = null,
        $role = null,
        $user = null,
        \DateTime $createdAt = null)
    {
        if ($subject === null) {
            $subject = static::getDefaultSubject();
        }

        if ($body === null) {
            $body = static::getDefaultBody();
        }

        if ($priority === null) {
            $priority = static::getDefaultPriority();
        }

        if ($type === null) {
            $type = static::getDefaultType();
        }

        if ($channel === null) {
            $channel = static::getDefaultChannel();
        }

        if ($role === null) {
            $role = static::getDefaultRole();
        }

        if ($user === null) {
            $user = static::getDefaultUser();
        }

        if ($createdAt === null) {
            $createdAt = static::getDefaultCreatedAt();
        }

        /* @var $message Message */
        $message = new self($subject, $body, $priority, $type, $channel, $role, $user, $createdAt);

        return $message;
    }
684430
def add_role(self, role, description=None):
        
        new_group = AuthGroup(role=role, creator=self.client)
        try:
            new_group.save()
            return True
        except NotUniqueError:
            return False
423475
def create_role(resource_root,
                service_name,
                role_type,
                role_name,
                host_id,
                cluster_name="default"):
  
  apirole = ApiRole(resource_root, role_name, role_type,
                    ApiHostRef(resource_root, host_id))
  return call(resource_root.post,
      _get_roles_path(cluster_name, service_name),
      ApiRole, True, data=[apirole])[0]
211377
def create_role(self, **kwargs):
        """"""

        role = self.role_model(**kwargs)
        return self.put(role)
428975
private void addRolesToSubject(Subject subject, Set<String> userRoles) {
        if (userRoles == null) {
            userRoles = Collections.emptySet();
        }

        Map<String, Set<String>> attributes =
                SubjectUtils.getAttributes(subject);

        Set<String> roles = attributes.get(ROLE_KEY);
        if (roles == null) {
            roles = new HashSet<String>(userRoles);
            attributes.put(ROLE_KEY, roles);
        } else {
            roles.addAll(userRoles);
        }
        if (logger.isDebugEnabled()) {
            for (String role : userRoles) {
                logger.debug("added role: {}", role);
            }
        }
    }
1273793
def add_user_story(self, subject, **attrs):
        
        return UserStories(self.requester).create(
            self.id, subject, **attrs
        )
919599
private RaftRole createRole(RaftServer.Role role) {
    switch (role) {
      case INACTIVE:
        return new InactiveRole(this);
      case PASSIVE:
        return new PassiveRole(this);
      case PROMOTABLE:
        return new PromotableRole(this);
      case FOLLOWER:
        return new FollowerRole(this);
      case CANDIDATE:
        return new CandidateRole(this);
      case LEADER:
        return new LeaderRole(this);
      default:
        throw new AssertionError();
    }
  }
678228
def create(cls, service=Service(), private=False):
        
        response = service.send(SRequest('POST', cls.path, data={'private': private}))
        return cls.from_response(response, service=service)
1179740
def _cast(cls, base_info, take_ownership=True):
        

        type_value = base_info.type.value
        try:
            new_obj = cast(base_info, cls.__types[type_value])
        except KeyError:
            new_obj = base_info

        if take_ownership:
            assert not base_info.__owns
            new_obj._take_ownership()

        return new_obj
618912
def changeUserRole( dbid, userid, roleid, newroleid )
      @dbid, @userid, @roleid, @newroleid = dbid, userid, roleid, newroleid
      
      xmlRequestData = toXML( :userid, @userid )
      xmlRequestData << toXML( :roleid, @roleid )
      xmlRequestData << toXML( :newroleid, @newroleid )
      
      sendRequest( :changeUserRole, xmlRequestData )

      return self if @chainAPIcalls
      @requestSucceeded
    end
100728
def post(self):
        """"""
        self.reqparse.add_argument('name', type=str, required=True)
        self.reqparse.add_argument('color', type=str, required=True)
        args = self.reqparse.parse_args()

        role = Role()
        role.name = args['name']
        role.color = args['color']

        db.session.add(role)
        db.session.commit()
        auditlog(event='role.create', actor=session['user'].username, data=args)

        return self.make_response('Role {} has been created'.format(role.role_id), HTTP.CREATED)
103680
def create(self, instance):
        
        with self.flushing():
            if instance.id is None:
                instance.id = self.new_object_id()
            self.session.add(instance)
        return instance
190401
def new(attributes = {})
      resource = repository.scope { model.new(attributes) }
      self << resource
      resource
    end
491796
def create_guild_role(data)
      role_data = data['role']
      server_id = data['guild_id'].to_i
      server = @servers[server_id]
      new_role = Role.new(role_data, self, server)
      existing_role = server.role(new_role.id)
      if existing_role
        existing_role.update_from(new_role)
      else
        server.add_role(new_role)
      end
    end
1230497
def execute(self):
        

        role_name = self._command_args['role_name']
        url = self._command_args['url']
        no_input = self._command_args['no_input']
        role_directory = os.getcwd()
        msg = 'Initializing new role {}...'.format(role_name)
        LOG.info(msg)

        if os.path.isdir(role_name):
            msg = ('The directory {} exists. '
                   'Cannot create new role.').format(role_name)
            util.sysexit_with_message(msg)

        cookiecutter.main.cookiecutter(
            url,
            extra_context=self._command_args,
            no_input=no_input,
        )

        role_directory = os.path.join(os.getcwd(), role_name)
        msg = 'Initialized role in {} successfully.'.format(role_directory)
        LOG.success(msg)
116030
def new(self, *args, **kwargs):
        '''
'''
        return self.session().add(self.model(*args, **kwargs))