
    e                     &   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(                  ej*                  j,                         G d dej.                                      Zy)Create a Dataplex Entry Link.    )absolute_import)division)unicode_literals)
entry_link)util)
exceptions)base)resource_args)log)yamlc                   X    e Zd ZdZddiZed        Z ej                  d      d        Z	y)Creater   EXAMPLESaY  To create a Dataplex Entry Link, you need to provide the entry link ID, the
entry group, the location, the project, the entry link type, and a path to a
YAML file containing the entry references. The entry references file should
contain a list of dictionaries, each representing an entry reference.

For example, to create an entry link of entry link type
'projects/655216118709/locations/global/entryLinkTypes/synonym' named
'my-entry-link' using entry references from 'entry_references.yaml', run:

        $ {command} my-entry-link \
          --entry-group=my-entry-group \
          --location=us-central1 \
          --project=test-project \
          --entry-link-type=projects/655216118709/locations/global/entryLinkTypes/synonym \
          --entry-references=path/to/entry_references.yaml

Example of entry_references.yaml file:
```yaml
  - name: projects/test-project/locations/us-central1/entryGroups/my-entry-group/entries/my-entry-1
    type: SOURCE
    path: my_path
  - name: projects/test-project/locations/us-central1/entryGroups/my-entry-group/entries/my-entry-2
    type: TARGET
```
          c                     t        j                  | d       | j                  ddd       | j                  dt        dd       y )	Nz
to create.z--entry-link-typeTzRequired. The type of the entry link. It is a resource name of the EntryLinkType. Example: `projects/my-project/locations/global/entryLinkTypes/my-link-type`)requiredhelpz--entry-referencesa  Required. Path to a YAML or JSON file containing the entry references. The file should contain a list of dictionaries, each with "name", "type", and optional "path" keys. Example:
  -
    name: projects/test-project/locations/us-central1/entryGroups/my-entry-group/entries/my-entry-1
    type: SOURCE
    path: my_path
  -
    name: projects/test-project/locations/us-central1/entryGroups/my-entry-group/entries/my-entry-2
    type: TARGET)typer   r   )r   AddDataplexEntryLinkResourceArgadd_argumentstr)parsers    *lib/surface/dataplex/entry_links/create.pyArgszCreate.ArgsA   sT    11&,G
R	         z-Status code: {status_code}. {status_message}.c                 b   |j                   j                  j                         }	 t        j                  |j
                        }|st        j                  dd      t        j                  |      }t        j                         }|j                  j                  t        j                         j                  |j!                         |j#                         j%                         t        j                         j'                  |j(                  ||j%                                           }t+        j,                  |j.                  dj1                  |j2                  |j4                  |j6                               y # t        j                  $ r}t        j                  dd|       d }~ww xY w)	Nzentry-referenceszError parsing YAML file: z#The entry references file is empty.)entry_references_content)entryLinkTypeentryReferencesname)entryLinkIdparentgoogleCloudDataplexV1EntryLinkzLContent entry link in project [{0}] with location [{1}] in entry group [{2}])details)CONCEPTSr   Parser   	load_pathentry_referencesErrorr	   BadFileExceptionCreateEntryReferencesdataplex_utilGetClientInstance)projects_locations_entryGroups_entryLinksr   GetMessageModule;DataplexProjectsLocationsEntryGroupsEntryLinksCreateRequestNameParentRelativeNameGoogleCloudDataplexV1EntryLinkentry_link_typer   CreatedResourcer    format
projectsIdlocationsIdentryGroupsId)selfargsentry_link_refr   eentry_references_messagedataplex_cliententry_link_responses           r   Runz
Create.Runa   s}    ]]--335N!%0E0E!F
 $''
C 
  *??!9  $557O)SSZZ&&(dd&++-!((*779+8+I+I+K+j+j"22 8#002 ,k , 	e 	

   !6))**,,	
5 :: ''
 9!= s   E= =F.F))F.N)
__name__
__module____qualname____doc__detailed_helpstaticmethodr   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrB    r   r   r   r      sQ     &  -:  > 5445))r   r   N)rF   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   r,   googlecloudsdk.api_lib.utilr	   rI   googlecloudsdk.callioper
   #googlecloudsdk.command_lib.dataplexr   googlecloudsdk.corer   r   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHACommandr   rK   r   r   <module>rW      st    $ &  ' 6 A F ( . = # $ D%%++,lT\\ l - lr   