code: def assign_role(args: Namespace) -> None:
      # Valid CLI usage is enforced before even creating a session.
      if (args.username_to_assign is None) == (
          args.group_name_to_assign is None
      ):
          raise api.errors.BadRequestException(
              "must provide exactly one of --username-to-assign or --group-name-to-assign"
          )
  
      session = setup_session(args)
      user_assign, group_assign = make_assign_req(session, args)
      req = bindings.v1AssignRolesRequest(
          userRoleAssignments=user_assign,
          groupRoleAssignments=group_assign,
      )
      bindings.post_AssignRoles(session, body=req)
  
      scope = " globally"
      if args.workspace_name:
          scope = f" to workspace {args.workspace_name}"
      if len(user_assign) > 0:
          role_id = user_assign[0].roleAssignment.role.roleId
          print(
              f"assigned role '{args.role_name}' with ID {role_id} "
              + f"to user '{args.username_to_assign}' with ID {user_assign[0].userId}{scope}"
          )
      else:
          role_id = group_assign[0].roleAssignment.role.roleId
          print(
              f"assigned role '{args.role_name}' with ID {role_id} "
              + f"to group '{args.group_name_to_assign}' with ID {group_assign[0].groupId}{scope}"
          )
  
file_path: determined/harness/determined/cli/rbac.py
imports: from argparse import Namespace
  from collections import namedtuple
  from typing import Any, Dict, List, Set, Tuple
  import determined.cli.render
  from determined.cli import default_pagination_args, render, require_feature_flag, setup_session
  from determined.common import api
  from determined.common.api import authentication, bindings
  from determined.common.declarative_argparse import Arg, Cmd
label_desc: Use image node_id 8 for calling a global function with example usage: assign_role(args) without return types