class_docstr: Nginx keeps track of registered domains, updates nginx config and issues SSL certificates.
  Its internal state could be serialized to a file and restored from it using pydantic.
class_docstr_tok: ["Nginx","keeps","track","of","registered","domains",",","updates","nginx","config","and","issues","SSL","certificates",".","Its","internal","state","could","be","serialized","to","a","file","and","restored","from","it","using","pydantic","."]
code: def format_conf(
      cls,
      o: Union[Dict[str, Any], List[Tuple[str, Any]]],
      *,
      indent: int = 2,
      depth: int = 0,
  ) -> str:
      pad = " " * depth * indent
      text = ""
      pairs = o.items() if isinstance(o, dict) else o
      for key, value in pairs:
          if isinstance(value, (dict, list)):
              text += pad + key + " {\n"
              text += cls.format_conf(
                  value, indent=indent, depth=depth + 1
              )
              text += pad + "}\n"
          else:
              text += pad + f"{key} {value};\n"
      return text
  
file_path: dstack/gateway/src/dstack/gateway/services/nginx.py
imports: import logging
  import re
  import subprocess
  import tempfile
  from asyncio import Lock
  from functools import lru_cache
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Set, Tuple, Union
  from pydantic import BaseModel
  from dstack.gateway.common import run_async
  from dstack.gateway.errors import GatewayError
label_desc: Use image node_id 5 for calling the Nginx obj's underlying member method code with example usage: obj.format_conf(cls, o) and returns: text