
    V                         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  \R                   r " S S\R"                  5      r " S S\5      rS rS rS rS rS rS rg)z<Command line processing utilities for authorized orgs descs.    )absolute_import)division)unicode_literals)concepts)policies)repeated)concept_parsers)
exceptions)	resourcesc                   (   ^  \ rS rSrU 4S jrSrU =r$ )
ParseError   c                 J   > [         [        U ]  SR                  X5      5        g )NzIssue parsing file [{}]: {})superr   __init__format)selfpathreason	__class__s      Flib/googlecloudsdk/command_lib/accesscontextmanager/authorized_orgs.pyr   ParseError.__init__!   s!    	*
6==dKL     __name__
__module____qualname____firstlineno__r   __static_attributes____classcell__r   s   @r   r   r      s    M Mr   r   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )InvalidFormatError&   c           	         > UR                  5        Vs/ s H  oDR                  PM     nn[        [        U ]  USR                  USR                  U5      5      5        g s  snf )Na  Invalid format: {}

An authorized orgs desc file is a YAML-formatted list of authorized orgs descs, which are YAML objects with the fields [{}]. For example:

- name: my_authorized_orgs
  authorizationType: AUTHORIZATION_TYPE_TRUST.
  assetType: ASSET_TYPE_DEVICE.
  authorizationDirection: AUTHORIZATION_DIRECTION_TO.
  orgs:
  - organizations/123456789
  - organizations/234567890
, )
all_fieldsnamer   r$   r   r   join)r   r   r   message_classfvalid_fieldsr   s         r   r   InvalidFormatError.__init__(   s]    $1$<$<$>?$>qFF$>L?	
d,T
	( *004		,0G*IJ @s   Ar   r   r"   s   @r   r$   r$   &   s    J Jr   r$   c                    [        5       nU H9  nUR                  5       (       d  M  UR                  UR                  5       5        M;     U(       a7  [        U SR	                  SR                  U5      5      [        US   5      5      eg )NzUnrecognized fields: [{}]r'   r   )setall_unrecognized_fieldsupdater$   r   r*   type)r   
conditionsunrecognized_fields	conditions       r   _ValidateAllFieldsRecognizedr7   9   sx    i((**  !B!B!DE  
#**4995H+IJZ]  r   c                  ,    [         R                  " SSS9$ )Nauthorized_orgs_descz#The ID of the authorized orgs desc.)r)   	help_text)r    ResourceParameterAttributeConfigr   r   r   _GetAttributeConfigr<   E   s    		2	2!5
7 7r   c                  f    [         R                  " SS[        R                  " 5       [	        5       S9$ )Nz7accesscontextmanager.accessPolicies.authorizedOrgsDescsr9   )resource_nameaccessPoliciesIdauthorizedOrgsDescsId)r   ResourceSpecr   GetAttributeConfigr<   r   r   r   _GetResourceSpecrC   K   s-    			?*224/1	
3 3r   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)zAdd a resource argument for an authorized orgs desc.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
r9   zThe authorized orgs desc {}.T)requiredN)r	   ConceptParserForResourcerC   r   AddToParser)parserverbs     r   AddResourceArgrK   S   sC     ++$++D1	 ,  ![(r   c                 4    [         R                  " U SSSSS9  g )Nr9   orgszNOrgs must be organizations, in the form `organizations/<organizationsnumber>`.)additional_help)r   AddPrimitiveArgs)rI   s    r   AddAuthorizedOrgsDescUpdateArgsrP   c   s#    
@Br   c                 <   ^ [         R                  " U SU4S j5      $ )NrM   c                  8   > T R                  5       R                  $ )N)GetrM   )authorized_orgs_desc_results   r   <lambda>ParseOrgs.<locals>.<lambda>o   s    7;;=BBr   )r   ParsePrimitiveArgs)argsrT   s    `r   	ParseOrgsrY   m   s     		$	$
FB
D Dr   N)__doc__
__future__r   r   r    googlecloudsdk.calliope.conceptsr   /googlecloudsdk.command_lib.accesscontextmanagerr   $googlecloudsdk.command_lib.util.argsr   (googlecloudsdk.command_lib.util.conceptsr	   googlecloudsdk.corer
   r   REGISTRYErrorr   r$   r7   r<   rC   rK   rP   rY   r   r   r   <module>rc      ss    C &  ' 5 D 9 D * )M!! MJ J&	73) BDr   