
                            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S.r\R(                  " \R*                  R,                  5       " S S\R.                  5      5       r\\l        g)z5Set-custom-constraint command for the Org Policy CLI.    )absolute_import)division)unicode_literals)
exceptions)
completers)service)base)utils)logz      Sets a Custom Constraint from a JSON or YAML file. The custom
      constraint will be created if it does not exist, or updated if it
      already exists.
      z|      To set the custom constraint from the file on the path './sample_path', run:

        $ {command} ./sample_path
      )DESCRIPTIONEXAMPLESc                   .    \ rS rSrSr\S 5       rS rSrg)SetCustomConstraint-   z1Set a custom constraint from a JSON or YAML file.c                 D    U R                  SS[        R                  SS9  g )Ncustom_constraint_fileCUSTOM_CONSTRAINT_FILEz@Path to JSON or YAML file that contains the organization policy.)metavar	completerhelp)add_argumentr   FilesCompleter)parsers    1lib/surface/org_policies/set_custom_constraint.pyArgsSetCustomConstraint.Args1   s(    
 (++O	  Q    c                    [         R                  " U R                  5       5      n[        R                  " UR
                  U R                  5       5      nUR                  (       d  [        R                  " S5      eUR                  R                  S5      (       d&  [        R                  " SUR                  -   S-   5      e UR                  UR                  5      nXC:X  a  U$ UR!                  U5      n[        R"                  " UR                  S5        U$ ! [        R                   a7    UR                  U5      n[        R                  " UR                  S5        Us $ f = f)a  Creates or updates a custom constraint from a JSON or YAML file.

This first converts the contents of the specified file into a custom
constraint object. It then fetches the current custom constraint using
GetCustomConstraint. If it does not exist, the custom constraint is created
using CreateCustomConstraint. If it does, the retrieved custom constraint is
checked to see if it needs to be updated. If so, the custom constraint is
updated using UpdateCustomConstraint.

Args:
  args: argparse.Namespace, An object that contains the values for the
    arguments specified in the Args method.

Returns:
  The created or updated custom constraint.
z0Name field not present in the custom constraint.zorganizations/z+Name field contains invalid resource type: zC. Custom constraints can be created only on organization resources.zcustom constraint)org_policy_serviceOrgPolicyApiReleaseTrackr
   "GetCustomConstraintMessageFromFiler   namer   InvalidInputError
startswithGetCustomConstraintapi_exceptionsHttpNotFoundErrorCreateCustomConstraintr   CreatedResourceUpdateCustomConstraintUpdatedResource)selfargsorg_policy_apiinput_custom_constraintcustom_constraintcreate_responseupdate_responses          r   RunSetCustomConstraint.Run9   sN   " (44T5F5F5HIN#FF##T%6%6%8:"''((
<> >"''223CDD((
7
!
&
&'
OPQ Q(<<
!
&
&( 3$;;!O/446IJ ++ &==
!#o	1668KL	s   D AE#"E# N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r4   __static_attributes__r6   r   r   r   r   -   s    9Q Q)r   r   N)r;   
__future__r   r   r   apitools.base.pyr   r'   argcompleter    googlecloudsdk.api_lib.orgpolicyr   r   googlecloudsdk.callioper	   'googlecloudsdk.command_lib.org_policiesr
   googlecloudsdk.corer   DETAILED_HELPReleaseTracksr!   GACommandr   detailed_helpr6   r   r   <module>rJ      s{    < &  ' 9 " J ( > 9 #	
	
  D%%(()4$,, 4 *4n %2  !r   