code: def role_name_to_role_id(session: api.Session, role_name: str) -> int:
      # No need to use read-paginated since the number of roles is fixed and small.
      req = bindings.v1ListRolesRequest(limit=500, offset=0)
      resp = bindings.post_ListRoles(session=session, body=req)
      for r in resp.roles:
          if r.name == role_name and r.roleId is not None:
              return r.roleId
      raise api.errors.BadRequestException(
          f"could not find role name {role_name}"
      )
  
file_path: determined/harness/determined/common/api/_rbac.py
imports: from typing import Dict, List, Optional
  from determined.common import api
  from determined.common.api import bindings
label_desc: Use image node_id 1 for calling a global function with example usage: role_name_to_role_id(session, role_name) and returns: r