
                         N   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
r\S-   rSS0r\	R"                  " \	R$                  R&                  \	R$                  R(                  \	R$                  R*                  5       " S S\	R,                  5      5       rg)z!services api-keys update command.    )absolute_import)division)unicode_literals)apikeys)services_util)base)common_flags)logzgcloud services operations zwait {0}EXAMPLESa  
        To remove all restrictions of the key:

          $ {command} projects/myproject/keys/my-key-id --clear-restrictions

        To update display name and set allowed ips as server key restrictions:

          $ {command} projects/myproject/keys/my-key-id --display-name="test name" --allowed-ips=2620:15c:2c4:203:2776:1f90:6b3b:217,104.133.8.78

        To update annotations:

          $ {command} projects/myproject/keys/my-key-id --annotations=foo=bar,abc=def

        To update key's allowed referrers restriction:

          $ {command} projects/myproject/keys/my-key-id --allowed-referrers="https://www.example.com/*,http://sub.example.com/*"

        To update key's allowed ios app bundle ids:

          $ {command} projects/myproject/keys/my-key-id --allowed-bundle-ids=my.app

        To update key's allowed android application:

          $ {command} projects/myproject/keys/my-key-id --allowed-application=sha1_fingerprint=foo1,package_name=bar1 --allowed-application=sha1_fingerprint=foo2,package_name=bar2

        To update keys' allowed api target with multiple services:

          $ {command} projects/myproject/keys/my-key-id --api-target=service=bar.service.com --api-target=service=foo.service.com

        To update keys' allowed api target with service and method:

          $ {command} projects/myproject/keys/my-key-id  --flags-file=my-flags.yaml

          The content of 'my-flags.yaml' is as following:

          ```
            - --api-target:
                service: "foo.service.com"
            - --api-target:
                service: "bar.service.com"
                methods:
                - "foomethod"
                - "barmethod"
            ```
        c                   2    \ rS rSrSr\S 5       rS r\r	Sr
g)UpdateO   zUpdate an API key's metadata.c                     [         R                  " U SS9  [         R                  " U SS9  [         R                  " U 5        [        R
                  R                  U 5        g )Nz	to update)parsersuffix)r	   key_flagdisplay_name_flagadd_key_update_argsr   
ASYNC_FLAGAddToParser)r   s    'lib/surface/services/api_keys/update.pyArgsUpdate.ArgsU   sB    <""&E$$V,OO'    c                    [         R                  " 5       nUR                  nUR                  R                  R                  5       n/ nUR                  UR                  5       UR                  5       S9nUR                  S5      (       a,  UR                  S5        [         R                  " X5      Ul        UR                  S5      (       a"  UR                  S5        UR                  Ul        UR                  S5      (       a  UR                  S5        UR                  S5      (       a  UR                  S5        GOUR                  S5      (       a:  UR                  S5        UR                  UR                   S	9UR"                  l        OUR                  S
5      (       a:  UR                  S5        UR'                  UR(                  S9UR"                  l        OUR                  S5      (       a:  UR                  S5        UR-                  UR.                  S9UR"                  l        OYUR                  S5      (       aC  UR                  S5        UR3                  [         R4                  " X5      S9UR"                  l        UR                  S5      (       a6  UR                  S5        [         R8                  " X5      UR"                  l        UR=                  UR                  5       SR?                  U5      US9nUR@                  RC                  U5      nURD                  (       d  URF                  (       aO  [H        RK                  URL                  5      n	[N        RP                  RS                  SRK                  U	5      5        U$ [T        RV                  " URL                  [         RX                  5      n[T        RZ                  " U5        U$ )zRun command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.

Returns:
  None
)namerestrictionsannotationsdisplay_nameclear_annotationsclear_restrictionsr   allowed_referrersz%restrictions.browser_key_restrictions)allowedReferrersallowed_ipsz$restrictions.server_key_restrictions)
allowedIpsallowed_bundle_idsz!restrictions.ios_key_restrictions)allowedBundleIdsallowed_applicationz%restrictions.android_key_restrictions)allowedApplications
api_targetzrestrictions.api_targets,)r   
updateMaskv2KeyzcAsynchronous operation is in progress... Use the following command to wait for its completion:
 {0}).r   GetClientInstanceMESSAGES_MODULECONCEPTSkeyParseV2KeyRelativeNameV2RestrictionsIsSpecifiedappendGetAnnotationsr   r   displayNameV2BrowserKeyRestrictionsr"   r   browserKeyRestrictionsV2ServerKeyRestrictionsr$   serverKeyRestrictionsV2IosKeyRestrictionsr&   iosKeyRestrictionsV2AndroidKeyRestrictionsGetAllowedAndroidApplicationsandroidKeyRestrictionsGetApiTargets
apiTargets(ApikeysProjectsLocationsKeysPatchRequestjoinprojects_locations_keysPatchdoneasync_OP_WAIT_CMDformatr   r
   statusPrintr   WaitOperationGetOperationPrintOperationWithResponse)
selfargsclientmessageskey_refupdate_mask	key_protorequestopcmds
             r   Run
Update.Run\   s.    &&(F%%Hmm%%'GK!!#(2I2I2K  MI&&'%44TDi''("//i+,,',--(			-	.	.BC8@8Y8Y!33 9Z 95	5M**AB7?7W7W'' 8X 8)	4011>?4<4Q4Q!44 5R 56	1122BC8@8Y8Y ' E E!  9Z 9!	5 
		,	'	'56,3,A,A-	)??!!#88K( @ G 
	'	'	-	-g	6B77	  )

 --3VC[	: 	&&rww0D0DEb,,R0Ir    N)__name__
__module____qualname____firstlineno____doc__staticmethodr   r\   DETAILED_HELPdetailed_help__static_attributes__r^   r   r   r   r   O   s'     &( (@B  -r   r   N)rc   
__future__r   r   r   googlecloudsdk.api_lib.servicesr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.servicesr	   googlecloudsdk.corer
   OP_BASE_CMDrK   re   ReleaseTracksReleaseTrackALPHABETAGAUpdateCommandr   r^   r   r   <module>rt      s    ( &  ' 3 9 ( < #+J&,	/d T..33T5F5F5I5IK T K K r   