Ë
    €Ï;  ã                   ó†   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
Zd	Zd
Zd„ Zdd„Zd„ Zd„ Zd„ Zd„ Zy)z7Flags and helpers for Immersive Stream for XR commands.é    )Úabsolute_import)Údivision)Úunicode_literals)Úarg_parsers)Ú
exceptions)ÚlogNa    Flag used to specify region and capacity required for the service instance's availability.

  'region' is the region in which the instance is deployed.

  'capacity' is the maxium number of concurrent streaming sessions that the instance can support in the given region.
z‰    Flag used to specify the fallback url to redirect users to when this service instance is unable to provide the streaming experience.
c                 ó   — | S )zDRegionValidator is a no-op. The validation is handled in CLH server.© )Úregions    ú;lib/googlecloudsdk/command_lib/immersive_stream/xr/flags.pyÚRegionValidatorr   '   s   € à	€-ó    c                 ó,  — t        j                  dd«      }|rdnd}|j                  | t        |z   t        j                  t
        |t        j                  «       t        j                  d¬«      t        j                  d¬«      dœdd	g¬
«      |d¬«       y )Nz[0-9]+zcapacity must be a numberz
This is a repeatable flag.Ú é   )Úlower_bound)r   ÚcapacityÚenable_autoscalingÚautoscaling_bufferÚautoscaling_min_capacityr   r   )ÚspecÚrequired_keysÚappend)ÚhelpÚtypeÚrequiredÚaction)r   ÚRegexpValidatorÚadd_argumentÚ_REGION_CONFIG_ARG_HELP_TEXTÚArgDictr   Ú
ArgBooleanÚ
BoundedInt)ÚnameÚparserÚ
repeatabler   Úcapacity_validatorÚrepeatable_helps         r   ÚAddRegionConfigArgr)   ,   s—   € Ü"×2Ñ2ØÐ,óÐñ 7AÑ2Àb€/Ø×ÑØ
Ü'¨/Ñ9Ü×Ñä'Ø,Ü$/×$:Ñ$:Ó$<Ü$/×$:Ñ$:ÀqÔ$IÜ*5×*@Ñ*@ÈQÔ*Oñð " :Ð.ô	ð Øð õ r   c                 óò   — t         j                  j                  j                  j	                  | «      }|j
                  st        j                  d«       y|j                  st        j                  d«       yy)a  Rudimentary url validator.

  Args:
    url: String

  Returns:
    Whether the input string contains both a scheme and a network location. Note
    that this is a very rudimentary validator and does not work on all cases.
    Invalid urls may still pass this check.
  z+Invalid URL - The URL must contain a schemeFz5Invalid URL - The URL must contain a network locationT)	ÚsixÚmovesÚurllibÚparseÚurlsplitÚschemer   ÚerrorÚnetloc)ÚurlÚ
parsed_urls     r   ÚValidateUrlr5   C   sY   € ô y‰y×Ñ×%Ñ%×.Ñ.¨sÓ3€*Ø	×	Ò	Ü‡IIÐ;Ô<ØØ	×	Ò	Ü‡IIÐEÔFØØ	r   c                 ód   — | j                  «       } | dk(  s| dk(  ryt        j                  dd«      ‚)zÑValidates the mode input.

  Args:
    mode: String indicating the rendering mode of the instance. Allowed values
      are 3d and ar.

  Returns:
    True if the mode is supported by ISXR, False otherwise.
  Ú3dÚarTz--modezmode must be 3d or ar©Úlowerr   ÚInvalidArgumentException)Úmodes    r   ÚValidateModer=   X   s3   € ð 
‰‹€$Ø	ˆT‚\T˜T’\ØÜ×+Ñ+¨HÐ6MÓNÐNr   c                 ó¼   — | j                  «       } | dk(  ry| dk(  r,|r|j                  «       dk7  rt        j                  dd«      ‚yt        j                  dd«      ‚)a4  Validates the gpu_class input.

  Args:
    gpu_class: String indicating the GPU class of the instance. Allowed values
      are l4 and t4.
    mode: String indicating the rendering mode of the instance.

  Returns:
    True if the GPU class and mode combination is supported by ISXR, False
    otherwise.
  Út4TÚl4r7   z--gpu-classz l4 gpu-class must have --mode=3dzgpu-class must be l4 or t4r9   )Ú	gpu_classr<   s     r   ÚValidateGpuClassrB   h   sj   € ð o‰oÓ€)Ø$ÒØØ$ÒÙ4—:‘:“< 4Ò'Ü×/Ñ/Ø
Ð;óð ð Ü×+Ñ+ØÐ1ó	ð r   c                 ó  — i }| D ]<  }|||d   <   |j                  dd«      sŒd|v rd|v rŒ't        j                  d«        y t        |«      t        | «      k  r%t        j                  dj	                  |«      «       yy)	aˆ  Validates the region config args do not contain duplicate regions and have valid autoscaling configuration, if enabled.

  Args:
    region_configs: Either add_region or update_region ArgList from the
      instance update args
    operation_name: String indicating if operation is an add or update region
      operation

  Returns:
    True if the region_configs are valid. False if not.
  r   r   Fr   r   z^Must set autoscaling_buffer and autoscaling_min_capacity if enable_autoscaling is set to true.z+Duplicate regions in --{}-region arguments.T)Úgetr   r1   ÚlenÚformat)Úregion_configsÚoperation_nameÚregionsÚregion_configs       r   ÚValidateRegionConfigArgsrK   ‚   sŽ   € ð €'Û%€mØ'4€GˆM˜(Ñ#Ñ$Ø×ÑÐ-¨uÕ5Ø Ñ-Ø&¨-Ò7ä	‡iið0ôñ ð &ô 	ˆƒ\”C˜Ó'Ò'Ü‡IIØ5×<Ñ<¸^ÓLôð à	r   )TT)Ú__doc__Ú
__future__r   r   r   Úgooglecloudsdk.callioper   r   Úgooglecloudsdk.corer   Úsix.moves.urllib.parser+   r    Ú_FALLBACK_URL_HELP_TEXTr   r)   r5   r=   rB   rK   r
   r   r   Ú<module>rR      sN   ðñ >å &Ý Ý 'å /Ý .Ý #Û ð Ð ðÐ ò
ó
ò.ò*Oò ó4 r   