
    
                         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ZdZdZd Zd Zd Zd Zy)zOrg Policies utilities.    )absolute_import)division)unicode_literals)DecodeError)encoding)
exceptions)apis)yaml)filesNzconstraints/v1c                  6    t        j                  dt              S Ncloudresourcemanager)r	   GetClientInstanceORG_POLICIES_API_VERSION     ;lib/googlecloudsdk/api_lib/resource_manager/org_policies.pyOrgPoliciesClientr   !       			 6 8
: :r   c                  6    t        j                  dt              S r   )r	   GetMessagesModuler   r   r   r   OrgPoliciesMessagesr   &   r   r   c           
         t        j                  |       }|s$t        j                  dj	                  |             	 t        j                  |t        j                  |            }|S # t        t        t        j                  f$ rj 	 t        j                  ||      }Y |S # t        t        f$ r=}t        j                  dj	                  | t        j                  |                  d}~ww xY ww xY w)aG  Reads a YAML or JSON object of type message from local path.

  Args:
    path: A local path to an object specification in YAML or JSON format.
    message: The message type to be parsed from the file.

  Returns:
    Object of type message, if successful.
  Raises:
    files.Error, exceptions.ResourceManagerInputFileError
  zEmpty policy file [{0}]zEPolicy file [{0}] is not properly formatted YAML or JSON due to [{1}]N)r   ReadFileContentsr   ResourceManagerInputFileErrorformatr   PyValueToMessager
   load
ValueErrorAttributeErrorYAMLParseErrorJsonToMessager   six	text_type)pathmessagein_textresultes        r   GetFileAsMessager+   +   s     ""4('	

2
2!((.0 0
9&&w		'0BCF 
- nd&9&9	: 99%%gw7f 
- $ 9 44cmmA&679 999s)   )A( (C0B  C,/8C''C,,C0c                 B    | j                  t              r| S t        | z   S )N)
startswithCONSTRAINTS_PREFIX)constraint_ids    r   FormatConstraintr0   K   s"    01--r   )__doc__
__future__r   r   r   #apitools.base.protorpclite.messagesr   apitools.base.pyr   'googlecloudsdk.api_lib.resource_managerr   googlecloudsdk.api_lib.utilr	   googlecloudsdk.corer
   googlecloudsdk.core.utilr   r$   r.   r   r   r   r+   r0   r   r   r   <module>r9      sI     &  ' ; % > , $ * 
#  :
:
@.r   