
    }                        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 ddlmZ  ej*                  ej,                  j.                         G d dej0                               Zy)z=`gcloud dataplex data-taxonomies atttributes update` 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)Updatez!Update a Dataplex Data Attribute.EXAMPLESa  
          To update 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 run:
          data-readers as user:test@google.com and parent as `test-attribute-parent`, run:

              $ {command} test-attribute --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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d      }|j                  dddd        t        j                  j                  |       t        j                  |        y )!Nz
to update.z--descriptionFz"Description of the Data Attribute.)requiredhelpz--display-namez#Display Name of the Data Attribute.z--etagz*etag value of the Data Attribute resource.z--parentzqParent Data Attribute for the defined 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_READERSTz:At most one of --async | --validate-only can be specified.)mutexr   r   z--validate-only
store_truez:Validate the update 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/update.pyArgszUpdate.Args8   s   ))&,?
1  3 2  4 9  ;  A  B !** \ +  $$"  " R % 
 $$"  " R % 
 $$!  " Q % 
 %%k & N   " R    ""I # KK J	  L
 	OO,$$V,    z-Status code: {status_code}. {status_message}.c                 &   t        j                  |      }t        |      dk  rt        j                  d      |j
                  j                  j                         }t        j                         }|j                  j                  t        j                         j                  |j                         dj                  |      |j                   t        j"                  ||                  }t%        |dd      }|r t&        j(                  j+                  d       y t%        |dd      }|s.t        j,                  |      }t'        j.                  |d	
       |S t&        j(                  j+                  dj1                  ||j2                               |S )N   zIUpdate commands must specify at least one additional parameter to change.,)name
updateMaskvalidateOnly"googleCloudDataplexV1DataAttributevalidate_onlyFzValidation complete.async_zOperation was successful.)detailsz3Updating Data Attribute [{0}] with operation [{1}].)r   GenerateAttributeUpdateMasklenr   HttpExceptionCONCEPTSdata_attributeParsedataplex_utilGetClientInstance,projects_locations_dataTaxonomies_attributesPatchGetMessageModule=DataplexProjectsLocationsDataTaxonomiesAttributesPatchRequestRelativeNamejoinr3   %GenerateDataAttributeForUpdateRequestgetattrr   statusPrintWaitForOperationUpdatedResourceformatr/   )	selfargsupdate_maskdata_attribute_refdataplex_clientupdate_req_opr3   r4   responses	            r)   Runz
Update.Run   sb     ;;DAK
;!$$
U  55;;=#557O#PPVV&& 	

G
G#002yy-++/<223Et0M	 H NOM D/59M	jj-.T8U+F//>h	,"=?oJJ=DD 2 2	45 r+   N)
__name__
__module____qualname____doc__detailed_helpstaticmethodr*   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrR    r+   r)   r   r   !   sR    ) -& D- D-L 54457!7!r+   r   N)rV   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   r<   googlecloudsdk.api_lib.utilr   rY   googlecloudsdk.callioper	   r
   #googlecloudsdk.command_lib.dataplexr   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHACommandr   r[   r+   r)   <module>rg      sj    D &  ' 9 A F / ( . = < # D%%++,@T\\ @ -@r+   