
    a                         d Z ddlmZ ddlmZ ddlmZ ddl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dZ G d de	j$                        Zee_        y)z$Update endpoint association command.    )absolute_import)division)unicode_literalsN)association_api)base)
exceptions)association_flags)labels_utila
  
          Update a firewall endpoint association. Check the progress of
          association update by using
            `gcloud network-security firewall-endpoint-associations describe`.

          For more examples, refer to the EXAMPLES section below.

        a  
          To update labels k1 and k2, run:

            $ {command} my-assoc --zone=us-central1-a --project=my-proj --update-labels=k1=v1,k2=v2

          To remove labels k3 and k4, run:

            $ {command} my-assoc --zone=us-central1-a --project=my-proj --remove-labels=k3,k4

          To clear all labels from the firewall endpoint association, run:

            $ {command} my-assoc --zone=us-central1-a --project=my-proj --clear-labels
        )DESCRIPTIONEXAMPLESc                   .    e Zd ZdZg dZed        Zd Zy)Updatez,Update a Firewall Plus endpoint association.)z--clear-labelsz--remove-labelsz--update-labelsz--[no-]tls-inspection-policyz--[no-]disabledc                    t        j                  | j                         |       t        j                  |d       t        j
                  j                  |       t        j
                  j                  |d       |j                         }t        j                  |       |j                         }t        j                  |       |j                         }t        j                  | j                         |       t        j                  |       y )N60mT)r	   AddAssociationResourceReleaseTrack
AddMaxWaitr   
ASYNC_FLAGAddToParser
SetDefaultadd_mutually_exclusive_groupAddDisabledArg	add_groupr
   AddUpdateLabelsFlagsAddTLSInspectionPolicyAddNoTLSInspectionPolicyArg)clsparserouter_grouptls_and_labels_group	tls_groups        Elib/surface/network_security/firewall_endpoint_associations/update.pyArgszUpdate.ArgsB   s    ,,S-=-=-?H  /OO'OOvt,557K$$[1&002$$%9:$AACI,,S-=-=-?K11)<    c                    t        j                  | j                               }i }|j                  j                  j                         }|j                  |j                               }|t        j                  dd      |j                  d      rt        |dd      |d<   |j                  d      rO|j                  j                  j                         }|t        j                  d      |j                         |d<   nt        |dd      rd|d<   t        j                   j#                  |      }|j%                         rd|j&                  |d	<   |j)                  |j*                  j,                  j.                  |j&                        }|j0                  r|j&                  |d	<   |st        j2                  | j4                        |j6                  }	t9        j:                  |j<                  
      }
|j?                  |j                         |      }|	r|j                  d      sd|_         |S |jC                  |jE                  |      djA                  |j                               d|
      S )zUpdates an association with labels and TLS inspection policy.

    Args:
      args: argparse.Namespace, the parsed arguments.

    Returns:
      A long running operation if async is set, None otherwise.
    zfirewall-endpoint-associationz-Firewall endpoint association does not exist.disabledFtls_inspection_policyzTLS Inspection Policy resource path is either empty, malformed, or missing necessary flag `--tls-inspection-policy-region`.
NOTE: TLS Inspection Policy needs to be in the same region as Firewall Plus endpoint resource.no_tls_inspection_policy labels)seconds)nameupdate_fieldsformatdefaultz<waiting for firewall endpoint association [{}] to be updatedT)operation_refmessage
has_resultmax_wait)#r   Clientr   CONCEPTSfirewall_endpoint_associationParseDescribeAssociationRelativeNamer   InvalidArgumentExceptionIsSpecifiedgetattrr'   core_exceptionsErrorr
   DiffFromUpdateArgsMayHaveUpdatesr*   ApplymessagesFirewallEndpointAssociationLabelsValueneeds_updateMinimumArgumentException_valid_argumentsasync_datetime	timedeltar3   UpdateAssociationr.   WaitForOperationGetOperationRef)selfargsclientr-   associationoriginalparsed_policylabels_difflabels_updateis_asyncr3   	operations               r"   Runz
Update.RunT   s<    ##D$5$5$78FM--==CCEK))+*B*B*DEH//
)
9 
 
#")$
E"BmJ/0mm99??Am		##
 	
 0=/I/I/Km+,	15	9/1m+,""11$7K!!# (mH!''
//
5
5
A
A
//m 
	#	#"/"6"6h//0E0EFF{{H!!$--8H((%%'# ) I
  h'"",,Y7JVK,,./ #  r$   N)__name__
__module____qualname____doc__rH   classmethodr#   rY    r$   r"   r   r   7   s'    4 = ="Hr$   r   )r]   
__future__r   r   r   rJ   Fgooglecloudsdk.api_lib.network_security.firewall_endpoint_associationsr   googlecloudsdk.callioper   r   +googlecloudsdk.command_lib.network_securityr	   $googlecloudsdk.command_lib.util.argsr
   googlecloudsdk.corer=   DETAILED_HELPUpdateCommandr   detailed_helpr_   r$   r"   <module>ri      sX    + &  '  b ( . I < =2eT eP % r$   