
    p                         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  G d
 dej                        Zy)zcreate command.    )absolute_import)division)unicode_literals)serviceusage)base)common_args)log)
propertiesc                   &    e Zd ZdZed        Zd Zy)Createa  Create a service identity for a consumer.

  This command creates a service identity for a consumer. The supported
  consumers are projects, folders, and organizations.

  ## EXAMPLES

  To create a service identity for a project, run:

    $ {command} --service=example.googleapis.com --project=helloworld

  Using a project number:

    $ {command} --service=example.googleapis.com --project=1234567890

  To create a service identity for a folder, run:

    $ {command} --service=example.googleapis.com --folder=1234567890

  To create a service identity for an organization, run:

    $ {command} --service=example.googleapis.com --organization=1234567890
  c                 L   | j                  ddd       | j                  dd      }t        j                  d      j	                  |       t        j                  d	d
t        d      j	                  |       t        j                  dd
t        d      j	                  |       y
)zArgs is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go on
        the command line after this command. Positional arguments are allowed.
    z	--serviceTz-The service to create a service identity for.)requiredhelpz;Container resource where the service identity will be used.)mutexr   z0Project where the service identity will be used.)help_text_to_prependz--folderNz/Folder where the service identity will be used.)defaulttyper   z--organizationz5Organization where the service identity will be used.)add_argument	add_groupr   ProjectArgumentAddToParserr   Argumentint)parser	containers     'lib/surface/services/identity/create.pyArgszCreate.Args5   s     <  >   I ! I Ok)MM>	
 k)MMD	
 k)    c                    |j                   r'|j                   }t        j                  j                  }n|j                  r'|j                  }t        j                  j
                  }ng|j                  r|j                  }n4t        j                  j                  j                  j                  d      }t        j                  j                  }t        j                  ||j                  |      }d|vr!t        j                  j!                  d       |S t        j                  j!                  dj#                  |d                |S )zRun 'services identity create'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      response with service identity email and uniqueId.
    T)r   emailzService identity createdzService identity created: {0})folderr   ContainerTypeFOLDER_SERVICE_RESOURCEorganizationORG_SERVICE_RESOURCEprojectr
   VALUEScoreGetPROJECT_SERVICE_RESOURCEGenerateServiceIdentityservicer	   statusPrintformat)selfargsr   container_typeresponses        r   Runz
Create.RunW   s     {{++i#11IIn			##i#11FFn	LL	%%**22666E	#11JJn334<<H h 
jj12 O 
jj6==
7
 Or   N)__name__
__module____qualname____doc__staticmethodr   r4    r   r   r   r      s!    0  B r   r   N)r8   
__future__r   r   r   googlecloudsdk.api_lib.servicesr   googlecloudsdk.callioper   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer	   r
   CreateCommandr   r:   r   r   <module>rA      s6     &  ' 8 ( < # *[T [r   