Exemplo n.º 1
0
    def CreateGrrUser(
        self,
        username: str,
        user_type: Optional[int] = None,
        password: Optional[str] = None,
        email: Optional[str] = None,
    ) -> GrrUser:
        """Creates a new GRR user of a given type with a given username/password."""

        if not username:
            raise ValueError("Username can't be empty.")

        args = user_management_pb2.ApiCreateGrrUserArgs(username=username)

        if user_type is not None:
            args.user_type = user_type

        if password is not None:
            args.password = password

        if email is not None:
            args.email = email

        data = self._context.SendRequest("CreateGrrUser", args)
        if not isinstance(data, user_pb2.ApiGrrUser):
            raise TypeError(f"Unexpected response type: '{type(data)}'")

        return GrrUser(data=data, context=self._context)
Exemplo n.º 2
0
  def CreateGrrUser(self, username=None, user_type=None, password=None):
    """Creates a new GRR user of a given type with a given username/password."""

    if not username:
      raise ValueError("Username can't be empty.")

    args = user_management_pb2.ApiCreateGrrUserArgs(username=username)
    args.username = username

    if user_type is not None:
      args.user_type = user_type

    if password is not None:
      args.password = password

    data = self._context.SendRequest("CreateGrrUser", args)
    return GrrUser(data=data, context=self._context)