
    ]                        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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mZ ddlmZ  ej4                  ej6                  j8                  ej6                  j:                  ej6                  j<                         G d dej>                               Z ddde _!        y)z4Command for updating a Rule in a Compute Engine NAT.    )absolute_import)division)unicode_literals)base_classes)poller)waiter)base)flags)
nats_utils)rules_utils)log)	resourcesc                   &    e Zd ZdZed        Zd Zy)Updatez&Update a Rule in a Compute Engine NAT.c                    t        j                         | _        | j                  j                  |       t	        j
                  |dd       t	        j                  |       t        j                  |dd       t	        j                  |d       t	        j                  |       t        j                  j                  |       y )NupdateF)operation_typepluralzNAT containing the Rule)r   )required)routers_flagsRouterArgumentForNat
ROUTER_ARGAddArgumentrules_flagsAddRuleNumberArgAddNatNameArgcompute_flagsAddRegionFlagAddMatchArgAddIpAndRangeArgsForUpdater	   
ASYNC_FLAGAddToParser)clsparsers     0lib/surface/compute/routers/nats/rules/update.pyArgszUpdate.Args'   s    "779CNNNv&  Of%)( FU3**62OO'    c                    t        j                  | j                               }|j                  j                  }|j                  j
                  j                  }| j                  j                  ||j                        }|j                  }|j                   |di |j                               }|j                  }|j                  }	t        j                   ||	      }
t#        j$                  |
|      }t#        j&                  ||||
       |j)                  |j+                  |j,                  |j.                  |j1                         |            }t        j2                  j5                  |j6                  d|j,                  |j.                  d      }|j8                  r+t;        j<                  |dj?                  ||	      dd       |S |j                  j5                  |j1                         d	|j,                  |j.                  d      }tA        jB                  ||      }tE        jF                  ||d
j?                  ||	            S )N)projectregionrouterrouterResourcezcompute.regionOperations)r)   r*   )
collectionparamszRule [{0}] in NAT [{1}]Tz[Run the [gcloud compute operations describe] command to check the status of this operation.)kindis_asyncdetailszcompute.routersz Updating Rule [{0}] in NAT [{1}] )$r   ComputeApiHolderReleaseTrackclientmessagesapitools_clientroutersr   ResolveAsResourcer   ComputeRoutersGetRequestGetAsDictrule_numbernatr   FindNatOrRaiser   FindRuleOrRaiseUpdateRuleMessagePatchComputeRoutersPatchRequestr)   r*   NameREGISTRYParsenameasync_r   UpdatedResourceformatr   Pollerr   WaitFor)selfargsholderr6   service
router_refrequest_typer+   r=   nat_namer>   ruleresultoperation_reftarget_router_refoperation_pollers                   r%   Runz
Update.Run7   s   **4+<+<+>?F}}%%Hmm++33G2249I9IJJ44L[[<
(9(9(;<=F""KxxH

#
#FH
5C&&sK8D!!$fc:]]++&&$$??$!	 	, 	#$F &&,,-!)) ''
 - M {{	
(//XF3	4 m((..$!)) ''
 /  }}W.?@>>-*11+xHJ Jr'   N)__name__
__module____qualname____doc__classmethodr&   rY   r2   r'   r%   r   r   !   s     /( (5Jr'   r   zO
        *{command}* is used to update a Rule in a Compute Engine NAT.
        a=          To drain connections established using address-1 and use address-2 for
        all new connections matching Rule 1 in NAT nat-1, run:

          $ {command} 1 --nat=nat1 --router=my-router --region=us-central1
            --source-nat-drain-ips=address-1
            --source-nat-active-ips=address-2
        )DESCRIPTIONEXAMPLESN)"r]   
__future__r   r   r   googlecloudsdk.api_lib.computer   )googlecloudsdk.api_lib.compute.operationsr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   "googlecloudsdk.command_lib.computer
   r   *googlecloudsdk.command_lib.compute.routersr   /googlecloudsdk.command_lib.compute.routers.natsr   5googlecloudsdk.command_lib.compute.routers.nats.rulesr   r   googlecloudsdk.corer   r   ReleaseTracksr4   ALPHABETAGAUpdateCommandr   detailed_helpr2   r'   r%   <module>rq      s    ; &  ' 7 < . ( E M F V M # ) T..33T5F5F5I5IHJT HJHJZ		 r'   