
                            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lmZ ddlmZ  ej*                  ej,                  j.                         G d dej0                               Zy)z=`gcloud dataplex data-taxonomies atttributes create` command.    )absolute_import)division)unicode_literals)data_taxonomy)util)
exceptions)arg_parsers)base)resource_args)labels_util)logc                   X    e Zd ZdZddiZed        Z ej                  d      d        Z	y)Createz!Create a Dataplex Data Attribute.EXAMPLESa  
          To create Data Attribute `test-attribute` for Data Taxonomy `test-datataxonomy` in project `test-dataplex`
          at location `us-central1` with description as `test description` ,  display name as `displayName`,
          resource-readers as user:test@google.com, resource-writers as user:test@google.com, resource-owner as user:test@google.com,
          data-readers as user:test@google.com and parent as `test-attribute-parent`, run:

              $ {command} test-attribute-6 --location=us-central1 --project=test-dataplex'
              --data_taxonomy=test-datataxonomy --description='test description'
              --display-name='displayName' --resource-readers='user:test@google.com'
              --resource-writers='user:test@google.com' --resource-owners='user:test@google.com'
              --data-readers='user:test@google.com'
              --parent='test-attribute-parent'

          c                    t        j                  | d       | j                  ddd       | j                  ddd       | j                  ddd	       | j                  dd
      }|j                  ddg dt	        j
                         d       |j                  ddg dt	        j
                         d       |j                  ddg dt	        j
                         d       | j                  dd      }|j                  ddg dt	        j
                         d       | j                  dd      }|j                  dddd       t        j                  j                  |       t        j                  |        y )Nz
to create.z--descriptionFz"Description of the Data Attribute.)requiredhelpz--display-namez#Display Name of the Data Attribute.z--parentzqParent Data Attribute for the created Data Attribute. It can be attribute name or fully qualified attribute name.zSpec related to Dataplex Resource.Specified when applied to a resource (eg: Google Cloud Storage bucket, BigQuery, dataset, BigQuery table).z--resource-readersRESOURCE_READERSzThe set of principals to be granted reader role on the resource. Expected principal formats are user:$userEmail, group:$groupEmail)metavardefaultr   typer   z--resource-writersRESOURCE_WRITERSzThe set of principals to be granted writer role on the resource. Expected principal formats are user:$userEmail, group:$groupEmailz--resource-ownersRESOURCE_OWNERSzThe set of principals to be granted owner role on the resource. Expected principal formats are user:$userEmail, group:$groupEmailz\Specified when applied to data stored on the resource (eg: rows,columns in BigQuery Tables).z--data-readersDATA_READERST)mutexr   z--validate-only
store_truez:Validate the create action, but don't actually perform it.)actionr   r   )r   AddAttributeResourceArgadd_argument	add_groupr	   ArgListr
   
ASYNC_FLAGAddToParserr   AddCreateLabelsFlags)parserresource_acces_sepcdataacces_sepcasync_groups       9lib/surface/dataplex/data_taxonomies/attributes/create.pyArgszCreate.Args6   s   ))&,?
1  3 2  4  A  B !** \ +  $$"  " R %  $$"  " R % 
 $$!  " Q % 
 %%k & N   " R    "" # K J	  L
 	OO,$$V,    z-Status code: {status_code}. {status_message}.c                    |j                   j                  j                         }t        j                         }|j
                  j                  t        j                         j                  |j                         |j                         j                         |j                  t        j                  ||                  }t        |dd      }|r t         j"                  j%                  d       y t        |dd      }|sGt        j&                  |      }t!        j(                  |j*                  dj-                  |             |S t         j"                  j%                  dj-                  ||j*                               |S )	N)dataAttributeIdparentvalidateOnly"googleCloudDataplexV1DataAttributevalidate_onlyFzValidation complete.async_zData Attribute created [{0}])detailsz3Creating Data Attribute [{0}] with operation [{1}].)CONCEPTSdata_attributeParsedataplex_utilGetClientInstance,projects_locations_dataTaxonomies_attributesr   GetMessageModule>DataplexProjectsLocationsDataTaxonomiesAttributesCreateRequestNameParentRelativeNamer1   r   %GenerateDataAttributeForCreateRequestgetattrr   statusPrintWaitForOperationCreatedResourcenameformat)selfargsdata_attribute_refdataplex_clientcreate_req_opr1   r2   responses           r)   Runz
Create.Runx   sG    55;;=#557O#PPWW&& 	

H
H.335%,,.;;=++/<223Et0M	 I NOM D/59M	jj-.T8U+F//>h	
--06$%' oJJ=DD 2 2	45 r+   N)
__name__
__module____qualname____doc__detailed_helpstaticmethodr*   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrM    r+   r)   r   r      sP    ) -& ?- ?-B 544577r+   r   N)rQ   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   r7   googlecloudsdk.api_lib.utilr   rT   googlecloudsdk.callioper	   r
   #googlecloudsdk.command_lib.dataplexr   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHACommandr   rV   r+   r)   <module>rb      sg    D &  ' 9 A F / ( = < # D%%++,wT\\ w -wr+   