
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  \R(                   " S S\R*                  5      5       rg)z7Command to create a specified Batch resource allowance.    )absolute_import)division)unicode_literals)DecodeError)encoding)resource_allowances)arg_parsers)base)resource_args)
exceptions)log)yamlc                   >    \ rS rSrSr\S 5       r\S 5       rS r	Sr
g)Submit   aX  Create a Batch resource allowance.

This command creates a Batch resource allowance.

## EXAMPLES

The following command submit a resource allowance with config.json sample
config file
`projects/foo/locations/us-central1/resousrceAllowances/bar`:

  $ {command} projects/foo/locations/us-central1/resousrceAllowances/bar
  --config config.json
c                 z    [         R                  " U 5        U R                  S[        R                  " 5       SSS9  g )Nz--configTz(The config file of a resource allowance.)typerequiredhelp)r   &AddCreateResourceAllowanceResourceArgsadd_argumentr	   FileContents)parsers    /lib/surface/batch/resource_allowances/create.pyArgsSubmit.Args/   s8    88@
%%';	      c                 |    [         R                  " UR                  [        R                  " U5      5      nU$ ! [
        [        [        R                  4 ac     [         R                  " UR                  U5      n U$ ! [
        [        4 a*  n[        R                  " SR                  U5      5      eSnAff = ff = f)zParse into ResourceAllowance message using the config input.

Args:
     batch_msgs: Batch defined proto message.
     config: The input content being either YAML or JSON or the HEREDOC
       input.

Returns:
     The Parsed resource allowance message.
zUnable to parse config file: {}N)r   PyValueToMessageResourceAllowancer   load
ValueErrorAttributeErrorYAMLParseErrorJsonToMessager   r   Errorformat)cls
batch_msgsconfigresultes        r   _CreateResourceAllowanceMessage&Submit._CreateResourceAllowanceMessage:   s    L((

&
&		&(9f M (;(;< LL''
(D(DfM M +& L@GGJKKLLs'   59 B;!A==B7%B22B77B;c                 J   UR                   R                  R                  5       nUR                  5       nUR	                  5       R                  S5      S   nU[        R                  :X  a  S nU R                  5       n[        R                  " U5      nUR                  nUR                  5       nUR                  (       a  U R                  XqR                  5      nUR                  XCU5      n	[         R"                  R%                  SR'                  U	R(                  S95        U	$ )N/zCResourceAllowance {resourceAllowanceName} was successfully created.)resourceAllowanceName)CONCEPTSresource_allowanceParseParentRelativeNamesplitr   	INVALIDIDReleaseTrackr   ResourceAllowancesClientmessagesr    r*   r-   Creater   statusPrintr'   uid)
selfargsresource_allowance_reflocation_refresource_allowance_idrelease_trackbatch_clientr)   resource_allowance_msgresps
             r   Run
Submit.RunQ   s    !]]==CCE)002L2??AGGLRP  7 77"%%'M&??NL&&J'99;{{#CC
kk  -CD JJM	dhh	/ Kr    N)__name__
__module____qualname____firstlineno____doc__staticmethodr   classmethodr-   rJ   __static_attributes__rL   r   r   r   r      s4        ,r   r   N)rQ   
__future__r   r   r   #apitools.base.protorpclite.messagesr   apitools.base.pyr   googlecloudsdk.api_lib.batchr   googlecloudsdk.callioper	   r
    googlecloudsdk.command_lib.batchr   googlecloudsdk.corer   r   r   DefaultUniverseOnlyCommandr   rL   r   r   <module>r^      sV    > &  ' ; % < / ( : * # $ MT\\ M Mr   