
                         x   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r\S-   rSS0r\	R$                  \	R&                  " \	R(                  R*                  \	R(                  R,                  \	R(                  R.                  5       " S S\	R0                  5      5       5       rg)z!services api-keys create command.    )absolute_import)division)unicode_literals)apikeys)services_util)base)common_flags)log)
propertieszgcloud services operations zwait {0}EXAMPLESa  
        To create a key with display name and allowed IPs specified:

          $ {command} --display-name="test name" --allowed-ips=2620:15c:2c4:203:2776:1f90:6b3b:217,104.133.8.78

        To create a key with annotations:

         $ {command} --annotations=foo=bar,abc=def

        To create a key with user-specified key ID:

          $ {command} --key-id="my-key-id"

        To create a key with allowed referrers restriction:

          $ {command} --allowed-referrers="https://www.example.com/*,http://sub.example.com/*"

        To create a key with allowed IOS app bundle IDs:

          $ {command} --allowed-bundle-ids=my.app

        To create a key with allowed Android application:

          $ {command} --allowed-application=sha1_fingerprint=foo1,package_name=bar.foo --allowed-application=sha1_fingerprint=foo2,package_name=foo.bar

        To create a key with allowed API targets (service name only):

          $ {command} --api-target=service=bar.service.com --api-target=service=foo.service.com

        To create a key with service account:

          $ {command} --service-account=my-service-account

        To create a key with allowed API targets (service and methods are
        specified):

          $ {command} --flags-file=my-flags.yaml

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

        ```
        - --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)CreateR   zCreate an API key.c                     [         R                  " U SS9  [         R                  " U 5        [         R                  " U SS9  [         R                  " U 5        [
        R                  R                  U 5        g )Nz	to create)parsersuffix)r	   display_name_flagadd_key_create_argskey_id_flagservice_account_flagr   
ASYNC_FLAGAddToParser)r   s    'lib/surface/services/api_keys/create.pyArgsCreate.ArgsY   sP    ""&E$$V,F;?%%f-OO'    c                    [         R                  R                  R                  R	                  5       n[
        R                  " 5       nUR                  nUR                  UR                  5       S9nUR                  S5      (       a  UR                  Ul        UR                  S5      (       a)  UR                  UR                  S9UR                  l        OUR                  S5      (       a)  UR#                  UR$                  S9UR                  l        OUR                  S5      (       a)  UR)                  UR*                  S9UR                  l        OHUR                  S	5      (       a2  UR/                  [
        R0                  " X5      S
9UR                  l        UR                  S5      (       a%  [
        R4                  " X5      UR                  l        UR                  S5      (       a  [
        R8                  " X5      Ul        UR                  S5      (       a  UR<                  Ul        UR                  S5      (       a0  URA                  [
        RB                  " U5      UURD                  S9nO$URA                  [
        RB                  " U5      US9nURF                  RI                  U5      nURJ                  (       d  URL                  (       aO  [N        RQ                  URR                  5      n[T        RV                  RY                  SRQ                  U5      5        U$ [Z        R\                  " URR                  [
        R^                  5      n[Z        R`                  " U5        U$ )zRun command.

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

Returns:
  None
)restrictionsdisplay_nameallowed_referrers)allowedReferrersallowed_ips)
allowedIpsallowed_bundle_ids)allowedBundleIdsallowed_application)allowedApplications
api_targetannotationsservice_accountkey_id)parentv2KeykeyId)r,   r-   zcAsynchronous operation is in progress... Use the following command to wait for its completion:
 {0})1r   VALUEScoreproject	GetOrFailr   GetClientInstanceMESSAGES_MODULEV2KeyV2RestrictionsIsSpecifiedr   displayNameV2BrowserKeyRestrictionsr    r   browserKeyRestrictionsV2ServerKeyRestrictionsr"   serverKeyRestrictionsV2IosKeyRestrictionsr$   iosKeyRestrictionsV2AndroidKeyRestrictionsGetAllowedAndroidApplicationsandroidKeyRestrictionsGetApiTargets
apiTargetsGetAnnotationsr)   r*   serviceAccountEmail)ApikeysProjectsLocationsKeysCreateRequestGetParentResourceNamer+   projects_locations_keysr   doneasync_OP_WAIT_CMDformatnamer
   statusPrintr   WaitOperationGetOperationPrintOperationWithResponse)	selfargs
project_idclientmessages	key_protorequestopcmds	            r   Run
Create.Runa   s    ""''//99;J&&(F%%HH,C,C,EFI''"//i+,,

+
+#55 ,  3
 
		-	(	(

*
*d6F6F
*
G 2 
		.	/	/2:2O2O22 3P 3i/ 
		/	0	0

+
+")"G"G# ,  3 %%*1*?*?*Oi'&&%44TDi)**&*&:&:i#!!BB..z: C g BB..z:) C g 
	'	'	.	.w	7B77	  )

  &s	

 	&&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   R   s'    
 ( (DJ !-r   r   N)rc   
__future__r   r   r   googlecloudsdk.api_lib.servicesr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.servicesr	   googlecloudsdk.corer
   r   OP_BASE_CMDrK   re   UniverseCompatibleReleaseTracksReleaseTrackALPHABETAGACreateCommandr   r^   r   r   <module>ru      s    ( &  ' 3 9 ( < # *+J& 1 1h T..33T5F5F5I5IP!T P! P!r   