
    *                        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)z9`gcloud dataplex data-attribute-bindings 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 Binding.EXAMPLESa  
          To create Data Attribute Binding `test-attribute-binding` in project
          `test-dataplex` at location `us-central1` with resouce name 'testResource' and resource attributes
          a1 and a2. Test column 'testColumn1' attached to attribute 'a1' and 'testColumn2' attached to attribute 'a2' , run:

            $ {command} test-attribute-binding --project=test-dataplex --location=us-central1
            --resource='projects/test-dataplex/locations/us-central1/lakes/my-lake/zones/test-zone/entities/testResource'
            --resource-attributes='a1,a2'
            --paths=name=testColumn1,attributes=a1
            --paths=name=testColumn2,attributes=a2

          c                    t        j                  | d       | j                  ddd       | j                  ddd       | j                  ddd	       | j                  d
dg dt        j                         d       | j                  dd      }|j                  ddddt        j                  t        t        j                         dddg      d       |j                  dd       | j                  dddg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 Binding.)requiredhelpz--display-namez+Display Name of the Data Attribute Binding.z
--resourcezCThe resource name of the resource that is binded to Data Attribute.z--resource-attributes
ATTRIBUTESzbList of attributes to be associated with the resource. It should be fully qualified attribute name)metavardefaultr   typer   TzCreation options.)mutexr   z--pathsPATHappend)name
attributesr   r   )specrequired_keysa  The list of paths for items within the associated resource (eg. columns within a table) along with attribute bindings. The args can be passed as key value pair. Supported Keys are --path=name=value1,attributes=value2 ,See https://cloud.google.com/sdk/gcloud/reference/topic/escaping for details on using a delimiter other than a comma. Attribute name should be fully qualified attribute name.)r   actionr   r   r   z--path-file-namez=The name of the JSON or YAML file to define Path config from.)r   z--path-file-formatjsonyamlzThe format of the file to create the path. Specify either yaml or json. Defaults to json if not specified. Will be ignored if --file-name is not specified.)choicesr   )r   r   z--validate-only
store_truez:Validate the create action, but don't actually perform it.)r   r   r   )r   "AddDataAttributeBindingResourceArgadd_argumentr	   ArgList	add_groupArgDictstrr
   
ASYNC_FLAGAddToParserr   AddCreateLabelsFlags)parsergroupasync_groups      6lib/surface/dataplex/data_attribute_bindings/create.pyArgszCreate.Args4   s   44V5AC
9  ; :  < -  .
   "D  
 4.ABE	  )113 "<0
C  D( 
  
  ?	  A "" # 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      }|s\t        j&                  |      }t!        j(                  |j*                  dj-                  |j.                  |j0                               |S t         j"                  j%                  dj-                  ||j*                               |S )	N)dataAttributeBindingIdparentvalidateOnly)googleCloudDataplexV1DataAttributeBindingvalidate_onlyFzValidation complete.async_zCData Attribute Binding created in project [{0}] with location [{1}])detailsz;Creating Data Attribute Binding [{0}] with operation [{1}].)CONCEPTSdata_attribute_bindingParsedataplex_utilGetClientInstance(projects_locations_dataAttributeBindingsr   GetMessageModule;DataplexProjectsLocationsDataAttributeBindingsCreateRequestNameParentRelativeNamer8   r   ,GenerateDataAttributeBindingForCreateRequestgetattrr   statusPrintWaitForOperationCreatedResourcer   format
projectsIdlocationsId)selfargsattribute_binding_refdataplex_clientcreate_req_opr8   r9   responses           r0   Runz
Create.Run}   sU    !MM@@FFH#557O#LLSS&& 	

E
E#8#=#=#?(//1>>@++6C99$7@	 F ABM D/59M	jj-.T8U+F//>h	
--W6'22'3356
 oJJELL!=#5#5	78 r2   N)
__name__
__module____qualname____doc__detailed_helpstaticmethodr1   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrU    r2   r0   r   r      sR    1 -" F- F-P 544577r2   r   N)rY   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   r>   googlecloudsdk.api_lib.utilr   r\   googlecloudsdk.callioper	   r
   #googlecloudsdk.command_lib.dataplexr   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHACommandr   r^   r2   r0   <module>rj      sg    @ &  ' 9 A F / ( = < # D%%++,}T\\ } -}r2   