
    e                     &   S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r  SSKJr  SSKJ
r
  SS	KJr  SS
KJr  SSKJr  \R&                  \R(                  " \R*                  R,                  5       " S S\R.                  5      5       5       rg)Create a Dataplex Entry Link.    )absolute_import)division)unicode_literals)
entry_link)util)
exceptions)base)resource_args)log)yamlc                   `    \ rS rSrSrSS0r\S 5       r\R                  " S5      S 5       r
Srg	)
Create   r   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                     [         R                  " U S5        U R                  SSSS9  U R                  S[        SSS9  g )	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ArgsCreate.ArgsA   sT    11&,G
R	         z-Status code: {status_code}. {status_message}.c                 f   UR                   R                  R                  5       n [        R                  " UR
                  5      nU(       d  [        R                  " SS5      e[        R                  " US9n[        R                  " 5       nUR                  R                  [        R                  " 5       R                  UR!                  5       UR#                  5       R%                  5       [        R                  " 5       R'                  UR(                  UUR%                  5       S9S95      n[*        R,                  " UR.                  SR1                  UR2                  UR4                  UR6                  5      S9  g ! [        R                   a  n[        R                  " SSU 35      eS nAff = f)	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   Run
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= =F0F++F0 N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrD   __static_attributes__rF   r   r   r   r      sN     &  -:  > 445))r   r   N)rK   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   r.   googlecloudsdk.api_lib.utilr	   rN   googlecloudsdk.callioper
   #googlecloudsdk.command_lib.dataplexr   googlecloudsdk.corer   r   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHACommandr   rF   r   r   <module>r\      sr    $ &  ' 6 A F ( . = # $ D%%++,lT\\ l - lr   