
                         >   S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  \R&                  " \R(                  R*                  \R(                  R,                  5       " S S\R.                  5      5       rg)z>Command to update an Immersive Stream for XR service instance.    )absolute_import)division)unicode_literals)api_util)	instances)waiter)base)flags)resource_args)log)
properties)	resourcesc                   H    \ rS rSrSrSSS.r\S 5       r\S 5       rS r	S	r
g
)Update    z3Update an Immersive Stream for XR service instance.aL  
          Update an Immersive Stream for XR service instance.
          This command can be used to update one of the following:
            - the capacity for an existing region of the service instance
            - the content build version served by the instance
            - the fallback url to redirect users to when the service instance is
              unable to provide the streaming experience

          If updating the capacity, only one region may be updated for each
          command execution, and the new capacity may not be 0 or exceed the
          quota limit.
      a  
          To update the service instance `my-instance` to have capacity 2 for an
          existing region us-west1, run:

            $ {command} my-instance --update-region=region=us-west1,capacity=2

          To update the service instance `my-instance` to have capacity 1 for a
          new region us-east4, run:

            $ {command} my-instance --add-region=region=us-east4,capacity=1

          To update the service instance `my-instance` to remove the existing
          region us-east4, run:

            $ {command} my-instance --remove-region=us-east4

          To update the service instance `my-instance` to serve content version
          `my-version`, run:

            $ {command} my-instance --version=my-version

          To update the service instance `my-instance` to use fallback url
          `https://www.google.com`, run:

            $ {command} my-instance --fallback-url="https://www.google.com"
      )DESCRIPTIONEXAMPLESc                    U R                   (       a!  [        R                  " U R                   S5      $ U R                  (       aL  [	        [        U R                  5      5      [	        U R                  5      :  a  [        R                  " S5        gU R                  (       a!  [        R                  " U R                  S5      $ g)Naddz/Duplicate regions in --remove-region arguments.FupdateT)	
add_regionr
   ValidateRegionConfigArgsremove_regionlensetr   errorupdate_region)argss    3lib/surface/immersive_stream/xr/instances/update.py__ValidateArgsUpdate.__ValidateArgsM   s    ++DOOUCC	S##$	%D,>,>(?	?		CD++D,>,>II    c                 L   [         R                  " U SS9  U R                  SSSS9nUR                  SSS9  UR                  S	S
S9  [        R
                  " SUSSS9  [        R
                  " SUSSS9  UR                  SSSS9  [        R                  R                  U 5        g )Nz	to update)verbTzUpdate options)mutexrequiredhelpz	--versionz8Build version tag of the content served by this instance)r'   z--fallback-urlzjFallback url to redirect users to when this service instance is unable to provide the streaming experiencez--add-regionF)
repeatabler&   z--update-regionz--remove-regionzRegion to removeappend)r'   action)	r   AddInstanceResourceArg	add_groupadd_argumentr
   AddRegionConfigArgr	   
ASYNC_FLAGAddToParser)parsergroups     r   ArgsUpdate.Args\   s    ((kB4$=MNE	G  I 
y   
%%A	5UUD	 28  EOO'r"   c           	      V   [         R                  U5      (       d  g UR                  nUR                  nUR                  nUR
                  nUR                  nUR                  n[        R                  R                  S S[        R                  " U R                  5       5      [        R                  R                   R"                  R%                  SS9SUS.S9nU(       a'  [&        R(                  " U R                  5       X5      n	GOUU(       aC  [*        R,                  " U5      (       d  g [&        R.                  " U R                  5       X5      n	GOU(       a'  [1        U5      S:  a  [2        R4                  " S5        g O[U(       a'  [1        U5      S:  a  [2        R4                  " S	5        g O-U(       a&  [1        U5      S:  a  [2        R4                  " S
5        g [&        R$                  " U R                  5       UR7                  5       5      n
[&        R8                  " U R                  5       UUUU
S9nUc  g [&        R:                  " U R                  5       X5      n	[        R<                  " U R                  5       5      n[2        R>                  RA                  SRC                  U5      5        URD                  (       a:  [2        R>                  RA                  SRC                  U	RF                  5      5        U	$ [        R                  R                  U	RF                  S[        R                  " U R                  5       5      S9n[H        RJ                  " [H        RL                  " URN                  URP                  5      USRC                  U	RF                  5      5      n[        R                  R                  S S[        R                  " U R                  5       5      [        R                  R                   R"                  R%                  SS9SUS.S9n[2        RR                  " U5        U$ )Nz)stream.projects.locations.streamInstancesT)r&   global)
projectsIdlocationsIdstreamInstancesId)
collectionapi_versionparams   z]Only one region may be added at a time. Please try again with only one --add-region argument.zbOnly one region may be removed at a time. Please try again with only one --remove-region argument.zbOnly one region may be updated at a time. Please try again with only one --update-region argument.)add_region_configsupdate_region_configsremove_regionscurrent_instancezUpdate request issued for: [{}]z!Check operation [{}] for status.
z$stream.projects.locations.operations)r:   r;   z&Waiting for operation [{}] to complete)*r   _Update__ValidateArgsversionfallback_urlr   r   r   instancer   REGISTRYParser   GetApiVersionReleaseTrackr   VALUEScoreprojectGetr   UpdateContentBuildVersionr
   ValidateUrlUpdateFallbackUrlr   r   r   RelativeNameGenerateTargetLocationConfigsUpdateLocationConfigs	GetClientstatusPrintformatasync_namer   WaitForCloudOperationPoller"projects_locations_streamInstancesprojects_locations_operationsUpdatedResource)selfr   rC   rD   r>   r@   r?   instance_nameinstance_refresult_operationrA   target_location_configsclientoperation_resourceupdated_instanceinstance_resources                   r   Run
Update.Runo   s     &&llG$$L''N ..MMM%%++>**4+<+<+>?$++0088<<d<K#!.
	 , L "<<



|6	|,,"44T5F5F5H5AQ 
!"Q&
)) < >
 ' ~"
)) E G
 # !$%)
)) E G
"t'8'8':'3'@'@'BD ) G G



/ 5'+!- 
!	("88



|F  1 1 34FJJ6==mLM{{	jj;BB


! ""++119**4+<+<+>? 2 A ~~##F$M$M$*$H$H	J0778H8M8MN	P "**00>**4+<+<+>?$++0088<<d<K#!.
	 1  )*r"    N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodrB   r3   rh   __static_attributes__rj   r"   r   r   r       sE    ;

'-R   ( ($Yr"   r   N)ro   
__future__r   r   r   *googlecloudsdk.api_lib.immersive_stream.xrr   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   .googlecloudsdk.command_lib.immersive_stream.xrr
   r   googlecloudsdk.corer   r   r   ReleaseTracksrI   ALPHAGACommandr   rj   r"   r   <module>r}      sw    E &  ' ? @ . ( @ H # * ) D%%++T->->-A-ABgT\\ g Cgr"   