Gets the AppRole by the given name. If an AppRole does not exist by that
 name, +nil+ is returned.

 @example
   Vault.approle.role("testrole") #=> #<Vault::Secret lease_id="...">

 @return [Secret, nil]
421522
def role(name)
      json = client.get("/v1/auth/approle/role/#{encode_path(name)}")
      return Secret.decode(json)
    rescue HTTPError => e
      return nil if e.code == 404
      raise
    end
457247
def roles
      return [] if get_roles.nil?
      x = [get_roles].flatten.map do |role|
        role.respond_to?(:to_sym) ? role.to_sym : role
      end    
      x.first.kind_of?(Set) ? x.first.to_a : x
    end
485887
public Object get(String propName) {
        if (propName.equals("roles")) {
            return getRoles();
        }
        if (propName.equals("entitlements")) {
            return getEntitlements();
        }
        return null;
    }
364998
def role?(role_sym)
      role_sym = [role_sym] unless role_sym.is_a?(Array)

      roles.map { |r| r.name.underscore.to_sym }.any? { |user_role| role_sym.include?(user_role) }
    end
176093
def add_role name
      if allowed_role? name
        return if has_role? name
        role = Role.find_by(name: name.to_s)
        roles << role
      end
    end
742934
def get_by_id(role_id, custom_headers:nil)
      response = get_by_id_async(role_id, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end
1033695
public boolean hasRoleForUser(String name, String role) {
        List<String> roles = getRolesForUser(name);

        boolean hasRole = false;
        for (String r : roles) {
            if (r.equals(role)) {
                hasRole = true;
                break;
            }
        }

        return hasRole;
    }
1301745
def set_role_id(name, role_id)
      options = { role_id: role_id }
      client.post("/v1/auth/approle/role/#{encode_path(name)}/role-id", JSON.fast_generate(options))
      return true
    end
1278332
def get_role(self, name):
    
    return roles.get_role(self._get_resource_root(), self.name, name,
        self._get_cluster_name())
1200606
def get_token(required_role: Roles::PUBLIC)
        token = params[:token]

        # Look up the cache. If present, use it and skip the verification.
        # Use token itself (and not a session UUID) as part of the key so
        # it can be considered *verified*.
        @auth_session = Cache.get(kind: :session, token: token)

        # Cache miss. So proceed to verify the token and get user and
        # session data from database. Then set the cache for later.
        if @auth_session.nil?
          @auth_session = verify_token(token)
          @auth_session.role  # NOTE: no-op
          Cache.set({kind: :session, token: token}, @auth_session)
        end

        # Obtained session may not have enough permission. Check here.
        if @auth_session.role < required_role
          logger.error("Not enough permission (role: #{@auth_session.role})")
          raise UNAUTHORIZED_ERROR, "Invalid token"
        end
        @auth_user = @auth_session.user
        @token = @auth_session.token
        return true
      end
241205
def get_role(self, id=None, name=None):
        
        log.info("Picking role: %s (%s)" % (name, id))
        return self.roles[id or name]
1358200
def get_role(self, role_name, mount_point='approle'):
        
        return self._adapter.get('/v1/auth/{0}/role/{1}'.format(mount_point, role_name)).json()
530674
public static boolean hasRole(String roleName) {
        return getSubject() != null && roleName != null
                && roleName.length() > 0 && getSubject().hasRole(roleName);
    }
170999
def get(self, roleId):
        """"""
        role = db.Role.find_one(Role.role_id == roleId)

        if not role:
            return self.make_response('No such role found', HTTP.NOT_FOUND)

        return self.make_response({'role': role})
383555
def _fetch_app_role_token(vault_url, role_id, secret_id):
        """"""
        url = _url_joiner(vault_url, 'v1/auth/approle/login')
        resp = requests.post(url, data={'role_id': role_id, 'secret_id': secret_id})
        resp.raise_for_status()
        data = resp.json()
        if data.get('errors'):
            raise VaultException(u'Error fetching Vault token: {}'.format(data['errors']))
        return data['auth']['client_token']
410981
def get_role(self, role):
        
        role = AuthGroup.objects(role=role, creator=self.client).first()
        return role
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