
    O                         S 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.    N)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.GetSetInstantSnapshotLabelsRequestMessage-   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	)
_InstantSnapshot2   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   r1   _InstantSnapshot.__init__5   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   )r5   !ComputeInstantSnapshotsGetRequestr2   AsDictr   s    r   r   1_InstantSnapshot.GetInstantSnapshotRequestMessage@   s.    >>;; "
--


 " "r   c                 .    U R                   R                  $ r   )r5   ZoneSetLabelsRequestr   s    r   r&   +_InstantSnapshot.GetSetLabelsRequestMessageD   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)r5   'ComputeInstantSnapshotsSetLabelsRequestr2   rL   instantSnapshotrN   rF   rJ   r   ipsrK   reqs       r   r)   :_InstantSnapshot.GetSetInstantSnapshotLabelsRequestMessageG   sk    
..
@
@C%%..]]!^^@@ 11& A B	C Cr   r3   r2   r5   r   Nr   r	   r
   r   r   r1   classmethodr>   r   r&   r)   r   r   r   r   r.   r.   2   s.    H $ $"/Cr   r.   c                   @    \ rS rSrSrS r\S 5       rS rS r	S r
Srg	)
_RegionInstantSnapshotQ   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   r1   r2   r3   regionInstantSnapshotsr   r5   r6   s       r   r1   _RegionInstantSnapshot.__init__T   s,    ##D)ML11DMNr   c                     g)Nzcompute.regionOperationsr   r<   s    r   r>   -_RegionInstantSnapshot.GetOperationCollection[   s    %r   c                 j    U R                   R                  " S0 U R                  R                  5       D6$ rA   )r5   'ComputeRegionInstantSnapshotsGetRequestr2   rC   r   s    r   r   7_RegionInstantSnapshot.GetInstantSnapshotRequestMessage_   s.    >>AA "
--


 " "r   c                 .    U R                   R                  $ r   )r5   RegionSetLabelsRequestr   s    r   r&   1_RegionInstantSnapshot.GetSetLabelsRequestMessagec   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$ )NrI   )rL   rM   regionregionSetLabelsRequest)r5   -ComputeRegionInstantSnapshotsSetLabelsRequestr2   rL   rQ   rh   re   rJ   rR   s       r   r)   @_RegionInstantSnapshot.GetSetInstantSnapshotLabelsRequestMessagef   sk    
..
F
FC%%..}}###~~DD 11&  E  B	C Cr   rV   NrW   r   r   r   rZ   rZ   Q   s.    M & &"1Cr   rZ   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)r8   s    r   IsZonalro   p   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.
)ro   r.   rZ   )r8   r7   r9   s      r   GetInstantSnapshotInforq      s)     WFX66!&8<<r   )r   r+   googlecloudsdk.core.exceptionsr   sixr   with_metaclassABCMetaobjectr   r.   rZ   ro   rq   r   r   r   <module>rw      si    `  0 
X5 XS//VD .C- C>C3 C>#<=r   