
    ?                     2   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mZ ddlmZ  ej*                  ej,                  j.                  ej,                  j0                         G d dej2                               Zy)z'Command to update labels for addresses.    )absolute_import)division)unicode_literals)base_classes)poller)waiter)base)
exceptions)flags)labels_utilc                   *    e Zd ZdZdZed        Zd Zy)Updatea^  Update a Compute Engine address.

  *{command}* updates labels for a Compute Engine
  address.

  ## EXAMPLES

  To add/update labels 'k0' and 'k1' and remove labels with key 'k3' for address
  'example-address', run:

    $ {command} example-address --region=us-central1 \
      --update-labels=k0=value1,k1=value2 --remove-labels=k3

  Labels can be used to identify the address and to filter them as in:

    $ {parent_command} list --filter='labels.k1:value2'

  To list existing labels for address 'example-address', run:

    $ {parent_command} describe example-address --format="default(labels)"

  Nc                     t        j                  d      | _        | j                  j                  |       t	        j
                  |       y )NF)plural)r   AddressArgumentADDRESS_ARGAddArgumentr   AddUpdateLabelsFlags)clsparsers     'lib/surface/compute/addresses/update.pyArgszUpdate.Args:   s4    ++59COOO'$$V,    c           	         t        j                  | j                               }|j                  j                  }|j                  j
                  }| j                  j                  ||j                  t        j                  |j                              }t        j                  j                  |      }|j                         st        j                   dd      |j#                         dk(  rP|j$                  j'                   |j(                  di |j+                               }|j,                  j.                  }nO|j0                  j'                   |j2                  di |j+                               }|j4                  j.                  }|j7                  ||j8                        }	|	j:                  s|S |j#                         dk(  r|j=                  |j>                  |jA                         |j-                  |jB                  |	j8                              }
|j$                  jE                  |
      }|j                  jG                  |jH                  d      }tK        jL                  |j$                        }n|jO                  |j>                  |jA                         |jP                  |j5                  |jB                  |	j8                        	      }
|j0                  jE                  |
      }|j                  jG                  |jH                  d
      }tK        jL                  |j0                        }tS        jT                  ||djW                  |jA                                     S )N)scope_listerLABELSzEAt least one of --update-labels or --remove-labels must be specified.zcompute.globalAddresses)labelFingerprintlabels)projectresourceglobalSetLabelsRequestzcompute.globalOperations)
collection)r   r    regionregionSetLabelsRequestzcompute.regionOperationsz Updating labels of address [{0}] ),r   ComputeApiHolderReleaseTrackclientapitools_clientmessagesr   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListerr   DiffFromUpdateArgsMayHaveUpdatescalliope_exceptionsRequiredArgumentException
CollectionglobalAddressesGet ComputeGlobalAddressesGetRequestAsDictGlobalSetLabelsRequestLabelsValue	addressesComputeAddressesGetRequestRegionSetLabelsRequestApplyr   needs_update&ComputeGlobalAddressesSetLabelsRequestr   Namer   	SetLabelsParseselfLinkr   Poller ComputeAddressesSetLabelsRequestr#   r   WaitForformat)selfargsholderr(   r*   address_reflabels_diffaddresslabels_valuelabels_updaterequest	operationoperation_refoperation_pollers                 r   Runz
Update.Run@   s   **4+<+<+>?F]]**F}}%%H""44"88G 5 IK
 ""11$7K%%'99
 /0 0 #<<&&**
3(
3
3
Kk6H6H6J
KMg44@@l  $$
-(
-
-
E0B0B0D
EGg44@@l%%lGNNCM%%n#<<??%%##%!)!@!@&77")) "A "+ @ ,g ((227;i&&,,


)C - Em  v'='=>99%%##%##!)!@!@&77")) "A "+	 : ,g "",,W5i&&,,


)C - Em  v'7'78>>-*11+2B2B2DEG Gr   )__name__
__module____qualname____doc__r   classmethodr   rU   r%   r   r   r   r      s&    . +- -
<Gr   r   N)rY   
__future__r   r   r   googlecloudsdk.api_lib.computer   )googlecloudsdk.api_lib.compute.operationsr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   r
   r2   "googlecloudsdk.command_lib.computer   r-   ,googlecloudsdk.command_lib.compute.addresses$googlecloudsdk.command_lib.util.argsr   ReleaseTracksr'   ALPHABETAUpdateCommandr   r%   r   r   <module>rg      sz    . &  ' 7 < . ( E E > < D%%++T->->-C-CD\GT \G E\Gr   