
                         D    S r SSKJr  SSKJr  SSKJr  S rS rS rS rg	)
z'Utilities for unit operations commands.    )absolute_import)division)unicode_literalsc                     UR                  S5      (       d  U$ UR                  S5      (       d  UR                  S5      (       a  U$ 0 UR                  l        U$ )zRequest hook to handle use of --provision flag.

Args:
  unused_ref: A resource ref to the parsed resource.
  args: Parsed args namespace containing the flags.
  request: The request message to be modified.

Returns:
  The modified request message.
	provisionprovision_releaseprovision_input_variables)IsSpecifiedunitOperationr   
unused_refargsrequests      >lib/googlecloudsdk/command_lib/saas_runtime/unit_operations.pyHandleEmptyProvisionr      s[     
		+	&	&N	)**d.>.>!/ / N$&'!	.    c                     UR                  S5      (       d  U$ UR                  S5      (       d  UR                  S5      (       a  U$ 0 UR                  l        U$ )zRequest hook to handle use of --upgrade flag.

Args:
  unused_ref: A resource ref to the parsed resource.
  args: Parsed args namespace containing the flags.
  request: The request message to be modified.

Returns:
  The modified request message.
upgradeupgrade_releaseupgrade_input_variables)r
   r   r   r   s      r   HandleEmptyUpgrader   +   s[     
		)	$	$N	'((D,<,<- - N"$'	.r   c                 X    UR                  S5      (       d  U$ 0 UR                  l        U$ )zRequest hook to handle use of --deprovision flag.

Args:
  unused_ref: A resource ref to the parsed resource.
  args: Parsed args namespace containing the flags.
  request: The request message to be modified.

Returns:
  The modified request message.
deprovision)r
   r   r   r   s      r   HandleEmptyDeprovisionr   @   s-     
		-	(	(N&('#	.r   c                 z  ^ / SQn/ SQnS/n[        U4S jU 5       5      [        U4S jU 5       5      [        U4S jU 5       5      S.nUR                  5        H[  u  pxU(       a  M  [        UR                  U5      (       d  M+  [	        UR                  U5      c  MD  [        UR                  US5        M]     U$ )	a@  Request hook to handle updates to the operation type.

The declarative framework does not fully support one_of fields in updates. For
example, if the command 'saas-runtime unit-operations update --provision' is
run, the request will have an empty upgrade field but that field should not be
present at all. This hook will delete the unspecified one_of field from the
request.

Args:
  unused_ref: A resource ref to the parsed resource.
  args: Parsed args namespace containing the flags.
  request: The request message to be modified.

Returns:
  The modified request message.
)add_provision_input_variablesclear_provision_input_variablesclear_provision_releaser   r	   r    remove_provision_input_variables)add_upgrade_input_variablesclear_upgrade_input_variablesclear_upgrade_releaser   r   r   remove_upgrade_input_variablesr   c              3   F   >#    U  H  nTR                  U5      v   M     g 7fNr
   .0flagr   s     r   	<genexpr>1HandleOneOfOperationTypeUpdate.<locals>.<genexpr>w   s     J/$t''--/   !c              3   F   >#    U  H  nTR                  U5      v   M     g 7fr%   r&   r'   s     r   r*   r+   x   s     FT%%d++r,   c              3   F   >#    U  H  nTR                  U5      v   M     g 7fr%   r&   r'   s     r   r*   r+   y   s!     N<MD))$//<Mr,   )r   r   r   N)anyitemshasattrr   getattrsetattr)	r   r   r   provision_flagsupgrade_flagsdeprovision_flagsoperation_flags	operationis_specifieds	    `       r   HandleOneOfOperationTypeUpdater:   Q   s    "/- %o J/JJFFFN<MNN/ "1!6!6!8iLG))955G))95Ag##Y5 "9 
.r   N)	__doc__
__future__r   r   r   r   r   r   r:    r   r   <module>r>      s'    . &  '**"2r   