code: def __init__(
      self,
      protocol: str = "http",
      host_or_ip: str = "localhost",
      port: Optional[int] = 80,
      path: str = "",
      query: str = "",
  ) -> None:
      # in case a preferred port is listed but its not clear if an alternative
      # port was included in the supplied host_or_ip:port combo passed in earlier
      match_port = re.search(":[0-9]{1,5}", host_or_ip)
      if match_port:
          sub_grid_url: GridURL = GridURL.from_url(host_or_ip)
          host_or_ip = str(sub_grid_url.host_or_ip)  # type: ignore
          port = int(sub_grid_url.port)  # type: ignore
          protocol = str(sub_grid_url.protocol)  # type: ignore
          path = str(sub_grid_url.path)  # type: ignore
  
      prtcl_pattrn = "://"
      if prtcl_pattrn in host_or_ip:
          protocol = host_or_ip[: host_or_ip.find(prtcl_pattrn)]
          start_index = host_or_ip.find(prtcl_pattrn) + len(
              prtcl_pattrn
          )
          host_or_ip = host_or_ip[start_index:]
  
      self.host_or_ip = host_or_ip
      self.path: str = path
      self.port = port
      self.protocol = protocol
      self.query = query
  
imports: from __future__ import annotations
  import copy
  import os
  import re
  from typing import Optional
  from typing import Union
  from urllib.parse import urlparse
  import requests
  from typing_extensions import Self
  from ..serde.serializable import serializable
  from ..util.util import verify_tls
label_desc: Use image node_id 2 to create a new GridURL object  with example: obj = GridURL(protocol, host_or_ip, port, path, query)