Maps user-facing role names to strings used to identify them on resources.
773724
def get_linked_properties(cli_ctx, app, resource_group, read_properties=None, write_properties=None):
    """"""
    roles = {
        "ReadTelemetry": "api",
        "WriteAnnotations": "annotations",
        "AuthenticateSDKControlChannel": "agentconfig"
    }

    sub_id = get_subscription_id(cli_ctx)
    tmpl = '/subscriptions/{}/resourceGroups/{}/providers/microsoft.insights/components/{}'.format(
        sub_id,
        resource_group,
        app
    )
    linked_read_properties, linked_write_properties = [], []

    if isinstance(read_properties, list):
        propLen = len(read_properties)
        linked_read_properties = ['{}/{}'.format(tmpl, roles[read_properties[i]]) for i in range(propLen)]
    else:
        linked_read_properties = ['{}/{}'.format(tmpl, roles[read_properties])]
    if isinstance(write_properties, list):
        propLen = len(write_properties)
        linked_write_properties = ['{}/{}'.format(tmpl, roles[write_properties[i]]) for i in range(propLen)]
    else:
        linked_write_properties = ['{}/{}'.format(tmpl, roles[write_properties])]
    return linked_read_properties, linked_write_properties
1349469
private int rolesToMask(ArrayList<String> roles) {
        int mask = 0;
        if (roles != null) {
            for (String role: roles) {
                switch (role) {
                    case "client":
                        mask |= 1;
                        break;       // Client mask
                    case "peer":
                        mask |= 2;
                        break;       // Peer mask
                    case "validator":
                        mask |= 4;
                        break;  // Validator mask
                    case "auditor":
                        mask |= 8;
                        break;    // Auditor mask
                }
            }
        }

        if (mask == 0) mask = 1;  // Client
        return mask;
    }
521367
def roles_autocomplete(self, text, line, start_index, end_index):
        ""
        if '-' not in line:
            # Append a dash to each service, makes for faster autocompletion of
            # roles
            return [s + '-' for s in self.services_autocomplete(text, line, start_index, end_index)]
        else:
            key, role = line.split()[1].split('-', 1)
            if key not in self.CACHED_ROLES:
                service = api.get_cluster(self.cluster).get_service(key)
                roles = []
                for t in service.get_role_types():
                    for r in service.get_roles_by_type(t):
                        roles.append(r.name)

                self.CACHED_ROLES[key] = roles

            if not role:
                return self.CACHED_ROLES[key]
            else:
                return [r for r in self.CACHED_ROLES[key] if r.startswith(line.split()[1])]
1084158
def list_roles():
    
    click.echo(green('\nListing roles:'))
    click.echo(green('-' * 40))
    with get_app().app_context():
        roles = Role.query.all()
        if not roles:
            click.echo(red('No roles found'))
            return

        for index,role in enumerate(roles):
            click.echo('{}. {}: {}'.format(
                index + 1,
                yellow(role.handle),
                role.title
            ))

    click.echo()
145419
def parse_roles(self, fetched_role, params):
        
        role = {}
        role['instances_count'] = 'N/A'
        # When resuming upon throttling error, skip if already fetched
        if fetched_role['RoleName'] in self.roles:
            return
        api_client = params['api_client']
        # Ensure consistent attribute names across resource types
        role['id'] = fetched_role.pop('RoleId')
        role['name'] = fetched_role.pop('RoleName')
        role['arn'] = fetched_role.pop('Arn')
        # Get other attributes
        get_keys(fetched_role, role, [ 'CreateDate', 'Path'])
        # Get role policies
        policies = self.__get_inline_policies(api_client, 'role', role['id'], role['name'])
        if len(policies):
            role['inline_policies'] = policies
        role['inline_policies_count'] = len(policies)
        # Get instance profiles
        profiles = handle_truncated_response(api_client.list_instance_profiles_for_role, {'RoleName': role['name']}, ['InstanceProfiles'])
        manage_dictionary(role, 'instance_profiles', {})
        for profile in profiles['InstanceProfiles']:
            manage_dictionary(role['instance_profiles'], profile['InstanceProfileId'], {})
            role['instance_profiles'][profile['InstanceProfileId']]['arn'] = profile['Arn']
            role['instance_profiles'][profile['InstanceProfileId']]['name'] = profile['InstanceProfileName']
        # Get trust relationship
        role['assume_role_policy'] = {}
        role['assume_role_policy']['PolicyDocument'] = fetched_role.pop('AssumeRolePolicyDocument')
        # Save role
        self.roles[role['id']] = role
906205
protected function load_role_mappings() {
        require_once('locallib.php');

        $imsroles = new imsenterprise_roles();
        $imsroles = $imsroles->get_imsroles();

        $this->rolemappings = array();
        foreach ($imsroles as $imsrolenum => $imsrolename) {
            $this->rolemappings[$imsrolenum] = $this->rolemappings[$imsrolename] = $this->get_config('imsrolemap' . $imsrolenum);
        }
    }
1306718
def roles(*roles)
      opts = roles.last.is_a?(Hash) ? roles.pop : {}
      self.valid_roles = roles.flatten.map(&:to_sym)
      unless (opts[:dynamic] == false)
        self.define_dynamic_queries(self.valid_roles)
      end
    end
323873
def get_user_roles(self, user):
        

        # For SQL: user.roles is list of pointers to Role objects
        if isinstance(self.db_adapter, SQLDbAdapter):
            # user.roles is a list of Role IDs
            user_roles = [role.name for role in user.roles]


        # For others: user.roles is a list of role names
        else:
            # user.roles is a list of role names
            user_roles = user.roles

        return user_roles
103235
def roles(self):
        
        if self._roles is None:
            self._roles = RoleList(self._version, service_sid=self._solution['sid'], )
        return self._roles
1024128
def project_roles(self, project):
        
        path = 'project/' + project + '/role'
        _rolesdict = self._get_json(path)
        rolesdict = {}

        for k, v in _rolesdict.items():
            tmp = {}
            tmp['id'] = v.split("/")[-1]
            tmp['url'] = v
            rolesdict[k] = tmp
        return rolesdict
977300
def list_roles_for_user(self, user):
        
        user_id = utils.get_id(user)
        uri = "users/%s/roles" % user_id
        resp, resp_body = self.method_get(uri)
        if resp.status_code in (401, 403):
            raise exc.AuthorizationFailure("You are not authorized to list "
                    "user roles.")
        roles = resp_body.get("roles")
        return roles
1179447
def person_same_name_map(json_content, role_from):
    ""
    matched_editors = [(i, person) for i, person in enumerate(json_content)
                       if person.get('role') in role_from]
    same_name_map = {}
    for i, editor in matched_editors:
        if not editor.get("name"):
            continue
        # compare name of each
        name = editor.get("name").get("index")
        if name not in same_name_map:
            same_name_map[name] = []
        same_name_map[name].append(i)
    return same_name_map
688304
def user_name_attributes(user, service):
    """"""
    attributes = {}
    attributes['username'] = user.get_username()
    attributes['full_name'] = user.get_full_name()
    attributes['short_name'] = user.get_short_name()
    return attributes
46795
protected Map<String, Role> parseDefinedRoles(Config config) {
        // Parse the defined Roles
        Map<String, Role> roleMap = new HashMap<>();
        if (!config.hasPath("roles")) {
            log.trace("'{}' has no roles", config);
        } else if (config.hasPath("roles")) {
            log.trace("Parsing Role definitions");
            Config roleConfig = config.getConfig("roles");
            for (Map.Entry<String, ConfigValue> entry : roleConfig.entrySet()) {
                String name = entry.getKey();
                List<String> permissions = roleConfig.getStringList(name);
                Role role = new Role(name, permissions.toArray(new String[permissions.size()]));
                roleMap.put(role.getName(), role);
            }
        }

        return Collections.unmodifiableMap(roleMap);
    }
1037089
def get_role_mapping(self, name=None, params=None):
        
        return self.transport.perform_request(
            "GET", _make_path("_security", "role_mapping", name), params=params
        )
884733
function defineManyRoles(roleMap) {
    if (!angular.isObject(roleMap)) {
      throw new TypeError('Parameter "roleNames" name must be object');
    }

    angular.forEach(roleMap, function (validationFunction, roleName) {
      defineRole(roleName, validationFunction);
    });
  }
972419
public Set<Role> findRoles(final Set<Group> userGroups)
    {
        final Set<Role> result = new HashSet<Role>();
        
        for(final RoleMapping mapping : this.getRoleMappings())
        {
            final Object source = mapping.getSource();
            
            if((userGroups != null) && userGroups.contains(source))
            {
                result.add(mapping.getTarget());
            }
        }
        
        return result;
    }