docstr: Possible values:
    - 8080
    - 80:8080
    - *:8080
docstr_tok: ["Possible","values",":","-","8080","-","80:8080","-","*",":8080"]
code: def parse(cls, v: str) -> "PortMapping":
      """
      Possible values:
        - 8080
        - 80:8080
        - *:8080
      """
      r = re.search(r"^(?:(\d+|\*):)?(\d+)?$", v)
      if not r:
          raise ValueError(v)
      local_port, container_port = r.groups()
      if local_port is None:  # identity mapping by default
          local_port = int(container_port)
      elif local_port == "*":
          local_port = None
      else:
          local_port = int(local_port)
      return PortMapping(
          local_port=local_port, container_port=int(container_port)
      )
  
imports: import re
  from enum import Enum
  from typing import Dict, List, Optional, Union
  from pydantic import BaseModel, Field, ValidationError, conint, constr, validator
  from typing_extensions import Annotated, Literal
  from dstack._internal.core.errors import ConfigurationError
  from dstack._internal.core.models.common import ForbidExtra
  from dstack._internal.core.models.repos.base import Repo
  from dstack._internal.core.models.repos.virtual import VirtualRepo
label_desc: Use image node_id 1 for calling the PortMapping obj's underlying member method code with example usage: obj.parse(cls, v) and returns: PortMapping