
    g                     ,   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	 ej                  ej                    ej"                  ej$                  j&                         G d
 dej(                                             Zy)z1Set-policy command for the Resource Settings CLI.    )absolute_import)division)unicode_literals)
completers)service)utils)base)
exceptionsc                   &    e Zd ZdZed        Zd Zy)UpdatezUpdate the value of a resource setting.

  Update the value of a resource setting.

  ## EXAMPLES

  To set the resource setting from the file with the path ``./sample_path'',
  run:

    $ {command} --setting-from-file="./test_input.json"
  c                 L    | j                  ddt        j                  dd       y )Nz--setting-from-filezsetting-from-fileTz=Path to JSON or YAML file that contains the resource setting.)metavar	completerrequiredhelp)add_argumentr   FilesCompleter)parsers    /lib/surface/resource_manager/settings/update.pyArgszUpdate.Args-   s+    
#++L  N    c                 F   t        j                         }t        j                  |j                  |j
                        }|j                  st        j                  d      t        j                  |j                        st        j                  d      t        j                  |j                        }t        j                  |      }|j                  }t        |d      r|j                  nd}t        j                  |||j                   |      }|j#                  |      }	|	S )zCreates or updates a setting from a JSON or YAML file.

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

    Returns:
      The created or updated setting.
    z/Name field not present in the resource setting.zName field has invalid syntaxetagN)r   ResourceSettingsMessagesr   GetMessageFromFilesetting_from_fileSettingnamer
   InvalidInputErrorValidateSettingPathGetResourceTypeFromString	api_utilsGetServiceFromResourceTypehasattrr   GetPatchRequestFromResourceTypevaluePatch)
selfargssettings_messageinput_settingresource_typesettings_servicesetting_pathr   update_requestupdate_responses
             r   Runz
Update.Run6   s     779 ,, 0 8 8:M ((
;= = $$]%7%78(()HII33M4F4FGM ;;MJ !%%L!(!?=TD>>|]%8%8$@N&,,^<Or   N)__name__
__module____qualname____doc__staticmethodr   r1    r   r   r   r      s"    
 N N"r   r   N)r5   
__future__r   r   r   argcompleter   0googlecloudsdk.api_lib.resource_manager.settingsr   r   r"   googlecloudsdk.callioper	   4googlecloudsdk.command_lib.resource_manager.settingsr
   HiddenDefaultUniverseOnlyReleaseTracksReleaseTrackALPHACommandr   r7   r   r   <module>rC      sw    8 &  ' " D O ( K F D%%++,8T\\ 8 -  8r   