// Roles returns an object that can list and get Roles.
171391
func (s *roleLister) Roles(namespace string) RoleNamespaceLister {
	return roleNamespaceLister{indexer: s.indexer, namespace: namespace}
}
277053
func (api *API) AccountRole(accountID string, roleID string) (AccountRole, error) {
	uri := fmt.Sprintf("/accounts/%s/roles/%s", accountID, roleID)

	res, err := api.makeRequest("GET", uri, nil)
	if err != nil {
		return AccountRole{}, errors.Wrap(err, errMakeRequestError)
	}

	var accountRole AccountRoleDetailResponse
	err = json.Unmarshal(res, &accountRole)
	if err != nil {
		return AccountRole{}, errors.Wrap(err, errUnmarshalError)
	}

	return accountRole.Result, nil
}
1126524
func (c *FakeRoles) List(opts v1.ListOptions) (result *v1alpha1.RoleList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(rolesResource, rolesKind, c.ns, opts), &v1alpha1.RoleList{})

	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &v1alpha1.RoleList{ListMeta: obj.(*v1alpha1.RoleList).ListMeta}
	for _, item := range obj.(*v1alpha1.RoleList).Items {
		if label.Matches(labels.Set(item.Labels)) {
			list.Items = append(list.Items, item)
		}
	}
	return list, err
}
601551
func (m *MockRbacV1Interface) Roles(arg0 string) v11.RoleInterface {
	ret := m.ctrl.Call(m, "Roles", arg0)
	ret0, _ := ret[0].(v11.RoleInterface)
	return ret0
}
372725
func (e *RoleService) Get(name string) (data *Role, err error) {
	path := fmt.Sprintf("roles/%s", name)
	err = e.client.magicRequestDecoder("GET", path, nil, &data)
	return
}
201746
func (rbac *RBAC) Get(id string) (r Role, parents []string, err error) {
	rbac.mutex.RLock()
	var ok bool
	if r, ok = rbac.roles[id]; ok {
		for parent := range rbac.parents[id] {
			parents = append(parents, parent)
		}
	} else {
		err = ErrRoleNotExist
	}
	rbac.mutex.RUnlock()
	return
}
1115662
func (j *AuroraJob) Role(role string) Job {
	j.jobConfig.Key.Role = role

	//Will be deprecated
	identity := &aurora.Identity{User: role}
	j.jobConfig.Owner = identity
	j.jobConfig.TaskConfig.Owner = identity
	return j
}
130176
func (cs *CryptoService) ListKeys(role data.RoleName) []string {
	var res []string
	for _, ks := range cs.keyStores {
		for k, r := range ks.ListKeys() {
			if r.Role == role {
				res = append(res, k)
			}
		}
	}
	return res
}
1249149
func newRoles(c *AuthorizationClient, namespace string) *roles {
	return &roles{
		client: c.RESTClient(),
		ns:     namespace,
	}
}
1312629
func (roles Roles) Check() (err error) {
	for _, role := range roles {
		if err = role.Check(); err != nil {
			return trace.Wrap(err)
		}
	}
	return nil
}
110839
func MarshalCertRoles(roles []string) (string, error) {
	out, err := json.Marshal(CertRoles{Version: V1, Roles: roles})
	if err != nil {
		return "", trace.Wrap(err)
	}
	return string(out), err
}
1139558
func (c *RolesStore) Add(ctx context.Context, u *chronograf.Role) (*chronograf.Role, error) {
	if err := c.Ctrl.CreateRole(ctx, u.Name); err != nil {
		return nil, err
	}
	if err := c.Ctrl.SetRolePerms(ctx, u.Name, ToEnterprise(u.Permissions)); err != nil {
		return nil, err
	}

	users := make([]string, len(u.Users))
	for i, u := range u.Users {
		users[i] = u.Name
	}
	if err := c.Ctrl.SetRoleUsers(ctx, u.Name, users); err != nil {
		return nil, err
	}
	return u, nil
}
374716
func (s *RoleService) ListRolePermissions(p *ListRolePermissionsParams) (*ListRolePermissionsResponse, error) {
	resp, err := s.cs.newRequest("listRolePermissions", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ListRolePermissionsResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
550528
func (s *RolesStore) Add(ctx context.Context, u *chronograf.Role) (*chronograf.Role, error) {
	return s.AddF(ctx, u)
}
1373984
func (cfg *Config) RoleConfig() RoleConfig {
	return RoleConfig{
		DataDir:     cfg.DataDir,
		HostUUID:    cfg.HostUUID,
		HostName:    cfg.Hostname,
		AuthServers: cfg.AuthServers,
		Auth:        cfg.Auth,
		Console:     cfg.Console,
	}
}
635417
func (c *FakeRoles) Get(name string, options v1.GetOptions) (result *v1beta1.Role, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewGetAction(rolesResource, c.ns, name), &v1beta1.Role{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1beta1.Role), err
}
371395
func (rm *RoleManager) GetUsers(name string, domain ...string) ([]string, error) {
	if len(domain) == 1 {
		name = domain[0] + "::" + name
	} else if len(domain) > 1 {
		return nil, errors.New("error: domain should be 1 parameter")
	}

	if !rm.hasRole(name) {
		return nil, errors.New("error: name does not exist")
	}

	names := []string{}
	rm.allRoles.Range(func(_, value interface{}) bool {
		role := value.(*Role)
		if role.hasDirectRole(name) {
			names = append(names, role.name)
		}
		return true
	})
	if len(domain) == 1 {
		for i := range names {
			names[i] = names[i][len(domain[0])+2:]
		}
	}
	return names, nil
}