
                             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 ej                   G d
 dej                               Zy)z7Command to update a specified Batch resource allowance.    )absolute_import)division)unicode_literals)resource_allowances)base)resource_args)
exceptions)logc                   ,    e Zd ZdZed        Zd Zd Zy)UpdateaI  Update a Batch resource allowance.

  This command updates a Batch resource allowance.

  ## EXAMPLES

  The following command updates a resource allowance limit to 0
  `projects/foo/locations/us-central1/resousrceAllowances/bar`:

    $ {command} projects/foo/locations/us-central1/resousrceAllowances/bar
    --usage-limit 0
  c                 T    t        j                  |        | j                  dd       y )Nz--usage-limitzvLimit value of a UsageResourceAllowance within its one
      duration. Limit cannot be a negative value. Default is 0.)help)r    AddResourceAllowanceResourceArgsadd_argument)parsers    /lib/surface/batch/resource_allowances/update.pyArgszUpdate.Args*   s,    226:
C      c                    | j                  |      }t        |      dk  rt        j                  d      | j	                         }t        j                  |      }|j                  j                  j                         }|j                  }|j                         }|j                  d      rPt        |d|j                  |j                  |j!                  t#        |j$                                                 |j'                  |||      }t(        j*                  j-                  dj/                  |j0                               |S )	N   zIUpdate commands must specify at least one additional parameter to change.usage_limitusageResourceAllowance)limit)speczCResourceAllowance {resourceAllowanceName} was successfully updated.)resourceAllowanceName)GenerateUpdateMasklenr	   ErrorReleaseTrackr   ResourceAllowancesClientCONCEPTSresource_allowanceParsemessagesResourceAllowanceIsSpecifiedsetattrUsageResourceAllowanceUsageResourceAllowanceSpecLimitfloatr   r   r
   statusPrintformatuid)	selfargsupdate_maskrelease_trackbatch_clientresource_allowance_ref
batch_msgsresource_allowance_msgresps	            r   Runz
Update.Run4   s5   ))$/K
;! 
 %%'M&??NL!]]==CCE&&J'99;&
 
"

+
+77&,, %d&6&6 7 -  8  ,   6D JJM	dhh	/ Kr   c                 N    g }|j                  d      r|j                  d       |S )z*Create Update Mask for ResourceAllowances.r   z'usageResourceAllowance.spec.limit.limit)r&   append)r0   r1   r2   s      r   r   zUpdate.GenerateUpdateMaskX   s*    K&BCr   N)__name__
__module____qualname____doc__staticmethodr   r9   r    r   r   r   r      s&      "Hr   r   N)r?   
__future__r   r   r   googlecloudsdk.api_lib.batchr   googlecloudsdk.callioper    googlecloudsdk.command_lib.batchr   googlecloudsdk.corer	   r
   DefaultUniverseOnlyCommandr   rA   r   r   <module>rI      sJ    > &  ' < ( : * # AT\\ A Ar   