
    f                     V    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 Z	d Z
d	 Zy
)z.Shared resource flags for datafusion commands.    )absolute_import)division)unicode_literals)iam_util)
console_ioc                     t        j                  | |      \  }}|j                  sd}t        j                  |dd       |S )a  Constructs an IAM Policy message from a JSON/YAML formatted file.

  Args:
    policy_file_path: Path to the JSON or YAML IAM policy file.
    policy_message_type: Policy message type to convert JSON or YAML to.
  Returns:
    a protorpc.Message of type policy_message_type filled in from the JSON or
    YAML policy file.
  Raises:
    BadFileException if the JSON or YAML file is malformed.
  zThe specified policy does not contain an "etag" field identifying a specific version to replace. Changing a policy without an "etag" can overwrite concurrent policy changes.zReplace existing policyT)messageprompt_stringcancel_on_no)r   ParseYamlOrJsonPolicyFileetagr   PromptContinue)policy_file_pathpolicy_message_typepolicyunused_maskmsgs        Blib/googlecloudsdk/command_lib/data_fusion/data_fusion_iam_util.pyParsePolicyFiler      sM     !::&+ 
C #<4Q	-    c                 @   |rQ|j                  | j                         d||j                  |            }|j                  j	                  |      S |j                  | j                         |j                  |            }|j                  j	                  |      S )z4Sets IAM policy for a given instance or a namespace.z/namespaces/)r   )resourcesetIamPolicyRequest)ADatafusionProjectsLocationsInstancesNamespacesSetIamPolicyRequestRelativeNameSetIamPolicyRequest'projects_locations_instances_namespacesSetIamPolicy7DatafusionProjectsLocationsInstancesSetIamPolicyRequestprojects_locations_instances)instance_ref	namespacenew_iam_policymessagesclientpolicy_requests         r   DoSetIamPolicyr'   3   s     __'3'@'@'BIN$88! 9 # ` $N 99FF  UU**,$88! 9 # V $N ..;;NKKr   c                 ,    | j                  ddd       y )Npolicy_filePOLICY_FILEa           Path to a local JSON or YAML file containing a valid policy.

        The output of the `get-iam-policy` command is a valid file, as is any
        JSON or YAML file conforming to the structure of a
        [Policy](https://cloud.google.com/iam/reference/rest/v1/Policy).
        )metavarhelp)add_argument)parsers    r   AddPolicyFileArgr/   H   s       	r   N)__doc__
__future__r   r   r   googlecloudsdk.command_lib.iamr   googlecloudsdk.core.consoler   r   r'   r/    r   r   <module>r5      s)    5 &  ' 3 24L*
r   