
    1                         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dZ G d dej                         Zee_        y)z'logging links create' command.    )absolute_import)division)unicode_literals)util)waiter)arg_parsers)base)log)	resourcesz7
        Create a linked dataset for a log bucket.
    zz
     To create a linked dataset in a project, run:

        $ {command} my-link --bucket=my-bucket --location=global
    )DESCRIPTIONEXAMPLESc                   &    e Zd ZdZed        Zd Zy)Createz3Create a linked dataset on an analytics log bucket.c                 :   | j                  dd       | j                  dd       t        j                  | d       t        j                  | dd       | j                  d	dt	        j
                  d
d      d       t        j                  j                  |        y)z Register flags for this command.LINK_IDz#ID of the linked dataset to create.)helpz--descriptionz-A textual description for the linked dataset.zlinked dataset to createTz:Location of the bucket that will hold the linked datasert.z--bucketz.+zmust be non-emptyz2ID of the bucket that will hold the linked dataset)requiredtyper   N)	add_argumentr   AddParentArgsAddBucketLocationArgr   RegexpValidatorr	   
ASYNC_FLAGAddToParser)parsers    #lib/surface/logging/links/create.pyArgszCreate.Args,   s     	(MN
M   	v9:D
 ((0CDA	   	OO'    c                 f   i }|j                  d      r|j                  |d<   t        j                         }|j                  j                  t        j                         j                  |j                  t        j                  t        j                  t        j                  |j                        j                         d|j                        d|j                         t        j                         j                  di |            }|j                   r$t#        j$                  |j&                  dd       |S t(        j*                  j-                  |j&                  d	      }t/        j0                  t/        j2                  |j4                        |d
j7                  |j&                              S )zThis is what gets called when the user runs this command.

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

    Returns:
      Linked dataset creation operation.
    description	locationsbuckets)linkIdparentlinkr%   T)is_asyncz%logging.projects.locations.operations)
collectionz&Waiting for operation [{}] to complete )IsSpecifiedr    r   	GetClient projects_locations_buckets_linksr   GetMessages1LoggingProjectsLocationsBucketsLinksCreateRequestr   CreateResourceNameGetProjectResourceprojectRelativeNamelocationbucketLinkasync_r
   CreatedResourcenamer   REGISTRYParseRelativeNamer   WaitForCloudOperationPollerNoResourcesprojects_locations_operationsformat)selfargs	link_dataclient	create_opcreate_op_refs         r   Runz
Create.RunA   sc    I&!%!1!1i^^F77>>LL<<**''++DLL9FFHMM
  )!!#((595 	M 	
I {{	)..&4@((::
..< ; m ^^

0
022 
2
9
9)..
I r   N)__name__
__module____qualname____doc__staticmethodr   rD   r(   r   r   r   r   )   s    ;( ((,r   r   N)rH   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r	   googlecloudsdk.corer
   r   DETAILED_HELPCreateCommandr   detailed_helpr(   r   r   <module>rR      sU     & &  ' / . / ( # )		DT DN % r   