
                             S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKr " S S\5      r	 " S	 S
\R                  " \R                  \5      5      r " S S\5      r " S S\5      rS rS rg)zYUtilities for handling Compute InstantSnapshotsService and RegionInstantSnapshotsService.    )absolute_import)division)unicode_literalsN)Errorc                       \ rS rSrSrSrg)UnknownResourceError   zORaised when a instant snapshot resource argument is neither regional nor zonal. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r
       =lib/googlecloudsdk/api_lib/compute/instant_snapshots_utils.pyr   r      s    Wr   r   c                       \ rS rSrSrS rS r\R                  S 5       r	\R                  S 5       r
\R                  S 5       rSrg	)
_CommonInstantSnapshot   z4Common class for InstantSnapshot Service API client.c                     U R                   $ N)_serviceselfs    r   
GetService!_CommonInstantSnapshot.GetService!   s    ==r   c                 X    U R                  5       nU R                  R                  U5      $ r   ) GetInstantSnapshotRequestMessager   Get)r   request_msgs     r   GetInstantSnapshotResource1_CommonInstantSnapshot.GetInstantSnapshotResource$   s%    779K==[))r   c                     [         er   NotImplementedErrorr   s    r   r   7_CommonInstantSnapshot.GetInstantSnapshotRequestMessage(       
r   c                     [         er   r$   r   s    r   GetSetLabelsRequestMessage1_CommonInstantSnapshot.GetSetLabelsRequestMessage,   r'   r   c                     [         er   r$   r   s    r   )GetSetInstantSnapshotLabelsRequestMessage@_CommonInstantSnapshot.GetSetInstantSnapshotLabelsRequestMessage0   r'   r   r
   N)r   r   r   r   r   r   r!   abcabstractmethodr   r)   r,   r   r
   r   r   r   r      s]    <*      r   r   c                   @    \ rS rSrSrS r\S 5       rS rS r	S r
Srg	)
_InstantSnapshot5   z@A wrapper for Compute Engine InstantSnapshotsService API client.c                 t    [         R                  U 5        X l        Xl        UR                  U l        X0l        g r   )r   __init___ips_ref_clientinstantSnapshotsr   	_messagesr   clientips_refmessagess       r   r4   _InstantSnapshot.__init__8   s,    ##D)ML++DMNr   c                     g)Nzcompute.zoneOperationsr
   clss    r   GetOperationCollection'_InstantSnapshot.GetOperationCollection?   s    #r   c                 j    U R                   R                  " S0 U R                  R                  5       D6$ Nr
   )r8   !ComputeInstantSnapshotsGetRequestr5   AsDictr   s    r   r   1_InstantSnapshot.GetInstantSnapshotRequestMessageC   s.    >>;; "
--


 " "r   c                 .    U R                   R                  $ r   )r8   ZoneSetLabelsRequestr   s    r   r)   +_InstantSnapshot.GetSetLabelsRequestMessageG   s    >>...r   c           
          U R                   R                  nU" U R                  R                  U R                  R                  U R                  R
                  U R                   R                  UR                  US9S9$ )NlabelFingerprintlabels)projectresourcezonezoneSetLabelsRequest)r8   'ComputeInstantSnapshotsSetLabelsRequestr5   rO   instantSnapshotrQ   rI   rM   r   ipsrN   reqs       r   r,   :_InstantSnapshot.GetSetInstantSnapshotLabelsRequestMessageJ   sk    
..
@
@C%%..]]!^^@@ 11& A B	C Cr   r6   r5   r8   r   Nr   r   r   r   r   r4   classmethodrA   r   r)   r,   r   r
   r   r   r1   r1   5   s.    H $ $"/Cr   r1   c                   @    \ rS rSrSrS r\S 5       rS rS r	S r
Srg	)
_RegionInstantSnapshotT   zEA wrapper for Compute Engine RegionInstantSnapshotService API client.c                 t    [         R                  U 5        X l        Xl        UR                  U l        X0l        g r   )r   r4   r5   r6   regionInstantSnapshotsr   r8   r9   s       r   r4   _RegionInstantSnapshot.__init__W   s,    ##D)ML11DMNr   c                     g)Nzcompute.regionOperationsr
   r?   s    r   rA   -_RegionInstantSnapshot.GetOperationCollection^   s    %r   c                 j    U R                   R                  " S0 U R                  R                  5       D6$ rD   )r8   'ComputeRegionInstantSnapshotsGetRequestr5   rF   r   s    r   r   7_RegionInstantSnapshot.GetInstantSnapshotRequestMessageb   s.    >>AA "
--


 " "r   c                 .    U R                   R                  $ r   )r8   RegionSetLabelsRequestr   s    r   r)   1_RegionInstantSnapshot.GetSetLabelsRequestMessagef   s    >>000r   c           
          U R                   R                  nU" U R                  R                  U R                  R                  U R                  R
                  U R                   R                  UR                  US9S9$ )NrL   )rO   rP   regionregionSetLabelsRequest)r8   -ComputeRegionInstantSnapshotsSetLabelsRequestr5   rO   rT   rk   rh   rM   rU   s       r   r,   @_RegionInstantSnapshot.GetSetInstantSnapshotLabelsRequestMessagei   sk    
..
F
FC%%..}}###~~DD 11&  E  B	C Cr   rY   NrZ   r
   r   r   r]   r]   T   s.    M & &"1Cr   r]   c                     U R                  5       S:X  a  gU R                  5       S:X  a  g[        SR                  U R                  5       5      5      e)a  Checks if a compute instant snapshot is zonal or regional.

Args:
  ips_ref: the instant snapshot resource reference that is parsed from
    resource arguments to modify.

Returns:
  Boolean, true when the compute instant snapshot resource to modify is a
  zonal compute instant snapshot resource, false when a regional compute
  instant snapshot resource.

Raises:
  UnknownResourceError: when the compute instant snapshot resource is not in
  the
    correct format.
zcompute.instantSnapshotsTzcompute.regionInstantSnapshotsFz3Unexpected instant snapshot resource argument of {})
Collectionr   format)r;   s    r   IsZonalrr   s   sU    ( 77??
=DD 	"# #r   c                 R    [        U 5      (       a  [        XU5      $ [        XU5      $ )a(  Gets the zonal or regional instant snapshot api info.

Args:
  ips_ref: the instant snapshot resource reference that is parsed from
    resource arguments.
  client: the compute api_tools_client.
  messages: the compute message module.

Returns:
  _ZoneInstantSnapshot or _RegionInstantSnapshot.
)rr   r1   r]   )r;   r:   r<   s      r   GetInstantSnapshotInfort      s)     WFX66!&8<<r   )r   
__future__r   r   r   r.   googlecloudsdk.core.exceptionsr   sixr   with_metaclassABCMetaobjectr   r1   r]   rr   rt   r
   r   r   <module>r{      sp    ` &  ' 
 0 
X5 XS//VD .C- C>C3 C>#<=r   