
    ~                        d 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  ej                  ej                  j                        ej                   G d d	ej                                       Z ej                  ej                  j$                        ej                   G d
 dej                                       Zy)zQuotaPreference update command.    N)encoding)quota_preference)base)flags)logc                   4    e Zd ZdZed        Zd ZddefdZy)UpdateAlpha  Update the parameters of a single QuotaPreference.

  This command updates an existing or creates a new QuotaPreference. It can
  updates the config in any states, not just the ones pending approval.

  ## EXAMPLES

  To update a quota preference with id `my-preference` in region `us-central1`
  that applies to the `default_limit` quota for `projects/12321`, run:

    $ {command} my-preference
    --service=example.$$UNIVERSE_DOMAIN$$
    --project=12321
    --quota-id=default_limit
    --preferred-value=100
    --dimensions=region=us-central1


  To create a new quota preference for `organizations/789`, run:

    $ {command} my-preference
    --service=example.$$UNIVERSE_DOMAIN$$
    --organization=789
    --quota-id=default_limit
    --preferred-value=200
    --allow-missing
  c                 6   t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j
                  d      j                  |        t        j                  | d       t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        yzArgs is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go on
        the command line after this command. Positional arguments are allowed.
    F)
positionalzquota preference to updateNr   PreferenceIdAddToParserServicePreferredValueQuotaIdAddResourceFlags
DimensionsEmailJustificationAllowMissingValidateOnlyAllowsQuotaDecreaseBelowUsage AllowHighPercentageQuotaDecreaseparsers    (lib/surface/quotas/preferences/update.pyArgszUpdateAlpha.Args9       
$$V,	MMO'	&&v.	MMU#//7	6#?@ 
""6*	KKMf%	%%f-	$$V,	$$V,	'')55f=	**,88@    c                     t        j                  |t        j                  j                        | _        |j                  | _        | j
                  S zRun command.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      The updated QuotaPreference. If `--validate-only` is specified, it returns
      None or any possible error.
    )release_track)r   UpdateQuotaPreferencer   ReleaseTrackGAupdated_resourcevalidate_onlyselfargss     r   RunzUpdateAlpha.RunQ   sD     -BBD--00D ++D   r!   resources_were_displayedc                     |ra| j                   sTt        j                  j                  t	        j
                  t        j                  | j                        ddd             y y y NT   ),:)	sort_keysindent
separators	r)   r   statusPrintjsondumpsr   MessageToDictr(   r+   r.   s     r   EpilogzUpdateAlpha.Epilogc   P    (:(:	jj
**$$T%:%:;#	 );r!   NT)	__name__
__module____qualname____doc__staticmethodr   r-   boolr>    r!   r   r	   r	      s.    8 A A.!$	T 	r!   r	   c                   .    e Zd ZdZed        Zd ZddZy)
UpdateBetar
   c                 6   t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j
                  d      j                  |        t        j                  | d       t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        t        j                         j                  |        yr   r   r   s    r   r   zUpdateBeta.Args   r    r!   c                     t        j                  |t        j                  j                        | _        |j                  | _        | j
                  S r#   )r   r%   r   r&   BETAr(   r)   r*   s     r   r-   zUpdateBeta.Run   sD     -BBD--22D ++D   r!   c                     |ra| j                   sTt        j                  j                  t	        j
                  t        j                  | j                        ddd             y y y r0   r7   r=   s     r   r>   zUpdateBeta.Epilog   r?   r!   Nr@   )rA   rB   rC   rD   rE   r   r-   r>   rG   r!   r   rI   rI   o   s'    8 A A.!"	r!   rI   )rD   r:   apitools.base.pyr   googlecloudsdk.api_lib.quotasr   googlecloudsdk.callioper   !googlecloudsdk.command_lib.quotasr   googlecloudsdk.corer   ReleaseTracksr&   ALPHAUniverseCompatibleUpdateCommandr	   rL   rI   rG   r!   r   <module>rW      s    &  % : ( 3 # D%%++,P$$$ P  -Pf D%%**+O## O  ,Or!   