Update with users which have role on project through a group.

        :param project_id: ID of the project
        :param roles: list of roles from keystone
        :param project_users: list to be updated with the users found
557294
def _get_users_from_groups(self, project_id, roles, project_users):
        

        # For keystone.group_list project_id is not passed as argument because
        # it is ignored when using admin credentials
        # Get all groups (to be able to find group name)
        groups = api.keystone.group_list(self.request)
        group_names = {group.id: group.name for group in groups}

        # Get a dictionary {group_id: [role_id_1, role_id_2]}
        project_groups_roles = api.keystone.get_project_groups_roles(
            self.request,
            project=project_id)

        for group_id in project_groups_roles:
            group_users = api.keystone.user_list(self.request,
                                                 group=group_id)
            group_roles_names = [
                role.name for role in roles
                if role.id in project_groups_roles[group_id]]

            roles_from_group = [(role_name, group_names[group_id])
                                for role_name in group_roles_names]

            for user in group_users:
                if user.id not in project_users:
                    # New user: Add the user to the list
                    project_users[user.id] = user
                    project_users[user.id].roles = []
                    project_users[user.id].roles_from_groups = []

                # Add roles from group
                project_users[user.id].roles_from_groups.extend(
                    roles_from_group)
51618
def get_users_in_project(self, projectname):
        
        ds_project = self.get_project(projectname)
        if ds_project is None:
            logger.error(
                "Project '%s' does not exist in MAM" % projectname)
            raise RuntimeError(
                "Project '%s' does not exist in MAM" % projectname)

        user_list = []
        if ds_project["Users"] != "":
            user_list = ds_project["Users"].lower().split(",")
        return user_list
1341964
public function add($project_id, $person_id)
    {
        $this->validates($project_id, $person_id);
        return $this->rest->post("projects/$project_id/people/$person_id");
    }
386723
function getUsersInProject(project) {
		return sharedProject.findOne({'location': project}).exec()
		.then(function(doc) {
			return doc ? doc.users : undefined;
		});
	}
1166219
def update_roles(role_ids)
      @roles = []
      role_ids.each do |id|
        # It is posible for members to have roles that do not exist
        # on the server any longer. See https://github.com/meew0/discordrb/issues/371
        role = @server.role(id)
        @roles << role if role
      end
    end
1006029
def set_role(project_root, environment)
      roles = Bebox::Role.list(project_root)
      nodes = Bebox::Node.list(project_root, environment, 'nodes')
      node = choose_option(nodes, _('wizard.choose_node'))
      role = choose_option(roles, _('wizard.choose_role'))
      output = Bebox::Provision.associate_node_role(project_root, environment, node, role)
      ok _('wizard.node.role_set_success')
      return output
    end
737160
def update_project(self, ID, data):
        """"""
        # http://teampasswordmanager.com/docs/api-projects/#update_project
        log.info('Update project %s with %s' % (ID, data))
        self.put('projects/%s.json' % ID, data)
1299478
def roles_for_user(request, user, project=None, domain=None):
    """"""
    manager = keystoneclient(request, admin=True).roles
    if VERSIONS.active < 3:
        return manager.roles_for_user(user, project)
    else:
        return manager.list(user=user, domain=domain, project=project)
634436
def update_role(id, name)
      current_path = "/api/v1/roles/#{id}/update"
      payload = { 'new_name' => name }.to_json
      @conn.put(current_path, payload)
    end
541531
public function update($projectId,$id, array $params)
    {
         $data = array('task'=>$params);
       
        return $this->put('/projects/'.urlencode($projectId).'/tasks/'.urlencode($id).'.json', $data);
    }
435920
@Patch("/metadata/{projectName}/tokens/{appId}")
    @Consumes("application/json-patch+json")
    public CompletableFuture<Revision> updateTokenRole(@Param("projectName") String projectName,
                                                       @Param("appId") String appId,
                                                       JsonPatch jsonPatch,
                                                       Author author) {
        final ReplaceOperation operation = ensureSingleReplaceOperation(jsonPatch, "/role");
        final ProjectRole role = ProjectRole.of(operation.value());
        return mds.findTokenByAppId(appId)
                  .thenCompose(token -> mds.updateTokenRole(author, projectName, token, role));
    }
1319497
def list_users
      update_users(:include_joins_and_parts) do
        users.values.each do |user|
          status = (user.idle? ? "G" : "H") + (user.admin? ? "@" : "")
          client.numeric_reply :rpl_whoreply, channel, user.account, user.server,
            "camper_van", user.nick, status, ":0 #{user.name}"
        end
        client.numeric_reply :rpl_endofwho, channel, "End of WHO list"
      end
    end
1172298
def addprojectmember(self, project_id, user_id, access_level):
        
        # if isinstance(access_level, basestring):
        if access_level.lower() == 'master':
            access_level = 40
        elif access_level.lower() == 'developer':
            access_level = 30
        elif access_level.lower() == 'reporter':
            access_level = 20
        else:
            access_level = 10

        data = {'id': project_id, 'user_id': user_id, 'access_level': access_level}

        request = requests.post(
            '{0}/{1}/members'.format(self.projects_url, project_id),
            headers=self.headers, data=data, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout)

        if request.status_code == 201:
            return True
        else:
            return False
1037341
public CompletableFuture<Revision> updateMemberRole(Author author, String projectName,
                                                        User member, ProjectRole projectRole) {
        requireNonNull(author, "author");
        requireNonNull(projectName, "projectName");
        requireNonNull(member, "member");
        requireNonNull(projectRole, "projectRole");

        final Change<JsonNode> change = Change.ofJsonPatch(
                METADATA_JSON,
                new ReplaceOperation(JsonPointer.compile("/members" + encodeSegment(member.id()) + "/role"),
                                     Jackson.valueToTree(projectRole)).toJsonNode());
        final String commitSummary = "Updates the role of the member '" + member.id() +
                                     "' as '" + projectRole + "' for the project " + projectName;
        return metadataRepo.push(projectName, Project.REPO_DOGMA, author, commitSummary, change);
    }
86459
function (userId, doc, fieldNames, modifier) {
			// only admins can update user roles via the client
			return Users.isAdmin(userId) || (doc._id === userId && fieldNames.indexOf("roles") < 0);
		}
491838
def add_role(user, roles):
        
        def _add_role(role):
            user_role = UserRole()
            user_role.user_id = user.user_id
            user_role.role_id = role.role_id
            db.session.add(user_role)
            db.session.commit()
        [_add_role(role) for role in roles]
1054752
def set_roles(role, reason = nil)
      role_ids = role_id_array(role)
      API::Server.update_member(@bot.token, @server.id, @user.id, roles: role_ids, reason: reason)
    end