
    T                       S r SSKJr  SSKJr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                  " 5       r\R"                  R$                  R&                  \R"                  R$                  R(                  \R"                  R$                  R*                  S	.rS
 rSS jr        SS jr      SS jr  S     SS jjrg)z6Client and utilities for the Dataplex Entry Links API.    )annotations)AnyList)util)
exceptions)parser_extensions)log)yaml)UNSPECIFIEDSOURCETARGETc                   / nU (       d  [         R                  " S5      eU  H  nUS   R                  5       n[        R	                  U5      nU(       d  [         R                  " SU S35      e[
        R                  US   US9nSU;   a
  US   Ul        UR                  U5        M     [        U5      S:w  a  [         R                  " S	5      eU$ )
zCreate Entry References.#The entry references file is empty.typezInvalid entry reference type: z/. Valid types are: UNSPECIFIED, SOURCE, TARGET.name)r   r   path   z;The entry references file must contain exactly two entries.)
r   BadFileExceptionupperENTRY_REFERENCE_TYPE_MAPPINGgetmodule,GoogleCloudDataplexV1EntryLinkEntryReferencer   appendlen)entry_references_contententry_references_messageentry_referencereference_type_inputreference_type_enumentry_reference_messages         1lib/googlecloudsdk/api_lib/dataplex/entry_link.pyCreateEntryReferencesr#   +   s    	!

%
%-  2o*6288:6::;OP''*+?*@ A; ; 
 	;; ($ 	< 	
   %4V%<"##$;<! 2" 		!"a'

%
%E  
"!    c                r   U R                   R                  R                  5       n [        R                  " U R
                  5      nU(       d  [        R                  " SS5      e[        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       [-        U S5      S9S95      n[.        R0                  " UR2                  S	R5                  UR6                  UR8                  UR:                  5      S
9  g! [        [        R                  4 a  n[        R                  " SSU 35      eSnAff = f)zCreate an EntryLink.zentry-referencesz$Error reading or parsing YAML file: Nr   )r   aspects)entryLinkTypeentryReferencesr   r&   )entryLinkIdparentgoogleCloudDataplexV1EntryLinkzLContent entry link in project [{0}] with location [{1}] in entry group [{2}])details)CONCEPTS
entry_linkParser
   	load_pathentry_referencesIOErrorErrorr   r   r#   dataplex_apiGetClientInstance)projects_locations_entryGroups_entryLinksCreateGetMessageModule;DataplexProjectsLocationsEntryGroupsEntryLinksCreateRequestNameParentRelativeNameGoogleCloudDataplexV1EntryLinkentry_link_type_GetArgValueOrNoner	   CreatedResourcer   format
projectsIdlocationsIdentryGroupsId)argsentry_link_refr   er   dataplex_cliententry_link_responses          r"   r7   r7   K   s   ==++113.#~~d.C.CD
 
"

%
%A 
 37 !224/'QQXX##%aa$))+&&(557)5)F)F)H)g)g 006!..0(y9	 *h * b 	 ''((**	
7 4::	 

%
%B1#F s    E= =F6F11F6c               .   [        5       nU R                  U5      (       a5  UR                  [        S U R	                  U5      R
                  5      5        U R                  U5      (       a   UR                  U R	                  U5      5        [        U5      $ )z?Generate a list of unique aspect keys to be updated or removed.c                    U R                   $ N)key)aspects    r"   <lambda>%_GenerateAspectKeys.<locals>.<lambda>   s    6::r$   )setIsKnownAndSpecifiedupdatemapGetValueadditionalPropertiessorted)rE   remove_aspects_arg_nameupdate_aspects_arg_namekeyss       r"   _GenerateAspectKeysr[   y   s{     
$	566KK%MM12GG	
 
566KK567	r$   c                T    U R                  U5      (       a  U R                  U5      $ S $ rL   )rR   rU   )rE   arg_names     r"   r?   r?      s(     %)$<$<X$F$Fx	 PDPr$   c                   U R                  U5      (       d,  U R                  U5      (       d  [        R                  " S5      eU R                  R                  R                  5       n[        R                  " 5       nUR                  R                  [        R                  UR                  5       [        R                  UR                  5       [        X5      S9[        U UUS9S95      n[         R"                  " UR                  5       SS9  U$ )z>Create an UpdateEntryLink request based on arguments provided.zIUpdate commands must specify at least one additional parameter to change.)r   r&   )rX   rY   )r   r+   
aspectKeys	EntryLink)kind)rR   r   HttpExceptionr-   r.   r/   r4   r5   r6   Patchr   :DataplexProjectsLocationsEntryGroupsEntryLinksPatchRequestr<   r=   r?   r[   r	   UpdatedResource)rE   rX   rY   rF   rH   resources         r"   Updaterg      s     677		!	!"9	:	:

"
"	  ==++113. 224/FFLLGG**,)/)N)N!..0(G *O * )&=&= H ( n113+F	/r$   N)rE   parser_extensions.Namespace)rE   rh   rX   strrY   ri   returnz	List[str])rE   rh   r]   ri   rj   z
Any | None)remove_aspectsupdate_aspects)rE   rh   rX   ri   rY   ri   )__doc__
__future__r   typingr   r   googlecloudsdk.api_lib.dataplexr   r4   googlecloudsdk.callioper   r   googlecloudsdk.corer	   r
   r8   r   r   TypeValueValuesEnumr   r   r   r   r#   r7   r[   r?   rg    r$   r"   <module>ru      s    = "  @ . 5 # $		&	&	(
 	;;OO[[ 	;;OOVV 	;;OOVV
  "@+\
% ! !	
 (Q
%Q14QQ $4#3
%  !r$   