
    ~                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r
  SSKJr  SS	KJr  \
R                   " 5       rS
\S\4S jrS\S\R(                  R*                  4S jrS\\   4S jrg)z(Utilities for Dataplex Entries commands.    )absolute_import)division)unicode_literalsN)List)util)messages)arg_parsersdatetime_strreturnc                 \    [         R                  R                  U 5      R                  5       $ )zWParses datetime string, validates it and outputs the new datetime string in ISO format.)r	   DatetimeParse	isoformat)r
   s    2lib/googlecloudsdk/command_lib/dataplex/parsers.pyIsoDateTimer      s"    				#	#L	1	;	;	==    aspects_filec           
         [         R                  " 5       nU" U 5      n[        U[        5      (       d  [         R                  " SU  S35      e/ nUR                  5        H_  u  pEUR                  [        R                  R                  R                  U[        R                  " U[        R                  5      S95        Ma     [        R                  R                  US9$ )a  Parse aspects from a YAML or JSON file.

Perform a basic validation that aspects are provided in a correct format.

Args:
  aspects_file: The path to the YAML/JSON file containing aspects.

Returns:
  A list of aspects parsed to a proto message (AspectsValue).
zInvalid aspects file: z. It must contain a map with a key in the format `ASPECT_TYPE@PATH` (or just `ASPECT_TYPE` if attached to the root path). Values in the map represent Aspect's content, which must conform to a template defined for a given `ASPECT_TYPE`.)keyvalue)additionalProperties)r	   YAMLFileContents
isinstancedictArgumentTypeErroritemsappenddataplex_messageGoogleCloudDataplexV1EntryAspectsValueAdditionalPropertymessages_utilDictToMessageWithErrorCheckGoogleCloudDataplexV1Aspect)r   parserraw_aspectsaspects
aspect_keyaspects         r   ParseAspectsr*   $   s     '')&|$+	K	&	&

'
'
  / 	  ''--/jNN33@@SS;;(DD 	T 	
 0 
	4	4	A	A" 
B 
 r   	ancestorsc                 8    U c  / $ [        [        S U 5      5      $ )zParse ancestors from a string.

Args:
  ancestors: A list of strings containing the JSON representation of the
    Ancestors.

Returns:
  A list of ancestors parsed to a proto message
  (GoogleCloudDataplexV1EntrySourceAncestor).
c                 t    [         R                  " [        R                  " U 5      [        R
                  5      $ )N)r"   r#   jsonloadsr   (GoogleCloudDataplexV1EntrySourceAncestor)ancestors    r   <lambda>+ParseEntrySourceAncestors.<locals>.<lambda>[   s$    =DDjj"GGr   )listmap)r+   s    r   ParseEntrySourceAncestorsr6   L   s.     I		 
 r   )__doc__
__future__r   r   r   r.   typingr   googlecloudsdk.api_lib.dataplexr   dataplex_utilgooglecloudsdk.api_lib.utilr   r"   googlecloudsdk.callioper	   GetMessageModuler   strr   r   r    r*   r6    r   r   <module>rA      sv    / &  '   A A / 113 >c >c >
%%00==%Pc r   