
                         h   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 rS r\
R(                  " \
R*                  R,                  \
R*                  R.                  \
R*                  R0                  5       " S S\
R2                  5      5       rg)z2gcloud dns response-policies rules update command.    )absolute_import)division)unicode_literals)util)apis)base)flags)resource_args)log)
propertiesc                     [         R                  " 5       R                  U 5        [         R                  " 5       R                  U 5        [         R                  " 5       R                  U 5        U R                  SSSS9  g)z+Adds the common arguments for all versions.z
--dns-nameFz3DNS name (wildcard or exact) to apply this rule to.)requiredhelpN)r	   GetLocalDataResourceRecordSetsAddToParserGetResponsePolicyRulesBehaviorGetLocationArgadd_argument)parsers    1lib/surface/dns/response_policies/rules/update.py_AddArgsCommonr      sd    &&(44V<&&(44V<$$V,@  B    c                 B   [         R                  " U5      n[        R                  " SU5      nUR	                  U [
        R                  R                  R                  R                  5       US9nUS:X  a  UR                  Ul
        UR                  R                  U5      $ )z'Get response policy rule to be Updated.dns)responsePolicyprojectresponsePolicyRulev2)r   GetApiClientr   GetMessagesModule DnsResponsePolicyRulesGetRequestr   VALUEScorer   GetlocationresponsePolicyRules)response_policyresponse_policy_ruleapi_versionargsclientmget_requests          r   _FetchResponsePolicyRuler.   ,   s     [)&
UK0!22$$$,,002- 3 /+ D==K		#	#	'	'	44r   c                   >    \ rS rSrSr\S 5       r\S 5       rS rSr	g)Update:   a  Updates a new Cloud DNS response policy rule.

This command updates a new Cloud DNS response policy rule.

## EXAMPLES

To update a new response policy rule with DNS name, run:

  $ {command} myresponsepolicyrule --response-policy="myresponsepolicy"
  --dns-name="www.newzone.com." # pylint: disable=line-too-long

To update a new response policy rule with local data rrsets, run:

  $ {command} myresponsepolicyrule --response-policy="myresponsepolicy"
  --local-data=name=www.zone.com.,type=A,ttl=21600,rrdatas=1.2.3.4

To update a new response policy rule with behavior, run:

  $ {command} myresponsepolicyrule --response-policy="myresponsepolicy"
  --behavior=bypassResponsePolicy
c                     U R                  5       [        R                   R                  [        R                   R                  4;   $ )N)ReleaseTrackr   BETAALPHA)clss    r   _BetaOrAlphaUpdate._BetaOrAlphaS   s:    $"3"3"8"8"&"3"3"9"9"; ; ;r   c                 |    [        U5        [        R                  " USSS9  UR                  R	                  S5        g )Nz	to updatev1)verbr)   json)r   r
   AddResponsePolicyRuleArgdisplay_info	AddFormat)r6   r   s     r   ArgsUpdate.ArgsX   s3    6**[d4
!!&)r   c           	         [         R                  " U R                  5       U5      n[         R                  " U5      n[        R
                  " SU5      nUR                  R                  R                  5       nUR                  5       nUR                  US9nUR                  UR                  S9n[        UR                  UR                  X!5      n	UR!                  S5      (       dM  UR!                  S5      (       d7  UR!                  S5      (       d!  ["        R$                  R'                  S5        U	$ UR!                  S5      (       a  UR(                  U	l        UR!                  S5      (       a  S U	l        / n
UR.                   Hq  nUR1                  UR3                  S5      UR3                  S	5      UR3                  S
5      UR3                  S5      R5                  S5      S9nU
R7                  U5        Ms     UR9                  U
S9U	l        UR!                  S5      (       a"  S U	l        [<        R>                  " X5      U	l        URA                  UR                  UR                  U	[B        RD                  RF                  RH                  RK                  5       S9nUS:X  a  URL                  Ul&        URN                  RQ                  U5      n["        RR                  " URT                  SS9  U$ )Nr   )ruleName)responsePolicyNamedns_name
local_databehaviorzNothing to update.nametypettlrrdatas|)rH   rI   rJ   rK   )
localDatas)r   r   responsePolicyRuleResourcer   r   ResponsePolicyRule)kind)+r   GetApiFromTrackAndArgsr3   r   r   r    CONCEPTSr(   ParseNamerO   ResponsePolicyr'   r.   rD   rC   IsSpecifiedr   statusPrintrE   dnsNamerG   rF   ResourceRecordSetgetsplitappendResponsePolicyRuleLocalData	localDatacommand_util ParseResponsePolicyRulesBehavior#DnsResponsePolicyRulesUpdateRequestr   r"   r#   r   r$   r%   r&   r0   UpdatedResourcer   )selfr*   r)   r+   messagesresponse_policy_rule_refresponse_policy_rule_namer(   r'   	to_updaterrsetsrrsetresource_record_set
update_requpdated_response_policy_rules                  r   Run
Update.Run_   s   --d.?.?.A4HK{+F%%e[9H  $}}AAGGI 8 = = ?#66* 7 , --// . 1O ))K)K)=)F)F)4<I J''0@0@1 1"..z::	jj+,
##--i%%if??%&886"6"		% IIi(..s3	 9 5
 	)* # %@@ A i 
## i'HH
i ==&99/88#,!!&&..224	 > 6J d MMj#)#=#=#D#DZ#P 4GG13 ('r    N)
__name__
__module____qualname____firstlineno____doc__classmethodr7   r@   rn   __static_attributes__rp   r   r   r0   r0   :   s4    , ; ; * *;(r   r0   N)ru   
__future__r   r   r   googlecloudsdk.api_lib.dnsr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.command_lib.dnsr	   r
   r`   googlecloudsdk.corer   r   r   r.   ReleaseTracksr3   r5   r4   GAUpdateCommandr0   rp   r   r   <module>r      s    9 &  ' + , ( 0 8 ? # *
B5 D%%++T->->-C-C%%((*^(T ^(*^(r   