
    F                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSK	J
r
  SSKr0 r\R                  " 5       \R                  " 5       4 H  r\\\R                   '   M     S	 r " S
 S\5      rg)z1Code related to proxy and emulator configuration.    )absolute_import)division)unicode_literalsN)datastore_util)pubsub_util)filesc                     [         R                  " U 5       VVs0 s H  u  p#X#R                  _M     nnn[        R                  " U[
        R                  " USS95        gs  snnf )a  This writes out the routes information to a file.

The routes will be written as json in the format
{service1: [route1, route2], service2: [route3, route4]}

Args:
  emulators: [str], emulators to route the traffic of
  output_file: str, file to write the configuration to
   indentN)six	iteritemsprefixesr   WriteFileContentsjsondumps)	emulatorsoutput_filenameemulatorroutess        2lib/googlecloudsdk/command_lib/emulators/config.pyWriteRoutesConfigr   %   sZ     #&--	":<": ###": 	 < +tzz&'CD<s   A c                   $    \ rS rSrSrS rS rSrg)ProxyConfiguration8   z0Configuration necessary to initialize the proxy.c                 (    Xl         X0l        X l        g)a  Initializes object.

Args:
  local_emulators: dict, the emulators and the ports they'll listen on
  should_proxy_to_gcp: bool, whether traffic to other emulators should
                       go to prod or not
  proxy_port: int, the port the proxy should bind to
N_local_emulators_proxy_port_should_proxy_to_gcp)selflocal_emulatorsshould_proxy_to_gcp
proxy_ports       r   __init__ProxyConfiguration.__init__;   s     ,! 3    c                     U R                   U R                  U R                  S.n[        R                  " U[
        R                  " USS95        g)zWrites configuration to file.

The format will be
{"localEmulators": {emulator1: port1, emulator2: port2},
 "proxyPort": port,
 "shouldProxyToGcp": bool}

Args:
  output_file: str, file to write to
)localEmulators	proxyPortshouldProxyToGcpr
   r   N)r   r    r!   r   r   r   r   )r"   r   datas      r   WriteJsonToFile"ProxyConfiguration.WriteJsonToFileH   sC     //%% 55D
 
KD)CDr(   r   N)__name__
__module____qualname____firstlineno____doc__r&   r.   __static_attributes__ r(   r   r   r   8   s    84Er(   r   )r4   
__future__r   r   r   r   $googlecloudsdk.command_lib.emulatorsr   r   googlecloudsdk.core.utilr   r   	EMULATORSDatastoreEmulatorPubsubEmulatorr   service_namer   objectr   r6   r(   r   <module>r?      sq    8 &  '  ? < * 
 	113++-/H%-)H!!"/
E& E  Er(   