
                             d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlZ G d de      Z	 G d	 d
 ej                  ej                  e            Z G d de      Z G d de      Zd Zd Zy)zYUtilities for handling Compute InstantSnapshotsService and RegionInstantSnapshotsService.    )absolute_import)division)unicode_literalsN)Errorc                       e Zd ZdZy)UnknownResourceErrorzORaised when a instant snapshot resource argument is neither regional nor zonal.N)__name__
__module____qualname____doc__     =lib/googlecloudsdk/api_lib/compute/instant_snapshots_utils.pyr   r      s    Wr   r   c                       e Zd ZdZd Zd Zej                  d        Zej                  d        Z	ej                  d        Z
y)_CommonInstantSnapshotz4Common class for InstantSnapshot Service API client.c                     | j                   S N)_serviceselfs    r   
GetServicez!_CommonInstantSnapshot.GetService!   s    ==r   c                 X    | j                         }| j                  j                  |      S r   ) GetInstantSnapshotRequestMessager   Get)r   request_msgs     r   GetInstantSnapshotResourcez1_CommonInstantSnapshot.GetInstantSnapshotResource$   s%    779K==[))r   c                     t         r   NotImplementedErrorr   s    r   r   z7_CommonInstantSnapshot.GetInstantSnapshotRequestMessage(       
r   c                     t         r   r   r   s    r   GetSetLabelsRequestMessagez1_CommonInstantSnapshot.GetSetLabelsRequestMessage,   r    r   c                     t         r   r   r   s    r   )GetSetInstantSnapshotLabelsRequestMessagez@_CommonInstantSnapshot.GetSetInstantSnapshotLabelsRequestMessage0   r    r   N)r	   r
   r   r   r   r   abcabstractmethodr   r"   r$   r   r   r   r   r      s]    <*      r   r   c                   8    e Zd ZdZd Zed        Zd Zd Zd Z	y)_InstantSnapshotz@A wrapper for Compute Engine InstantSnapshotsService API client.c                 z    t         j                  |        || _        || _        |j                  | _        || _        y r   )r   __init___ips_ref_clientinstantSnapshotsr   	_messagesr   clientips_refmessagess       r   r*   z_InstantSnapshot.__init__8   s2    ##D)DMDL++DMDNr   c                      y)Nzcompute.zoneOperationsr   clss    r   GetOperationCollectionz'_InstantSnapshot.GetOperationCollection?   s    #r   c                 j     | j                   j                  di | j                  j                         S Nr   )r.   !ComputeInstantSnapshotsGetRequestr+   AsDictr   s    r   r   z1_InstantSnapshot.GetInstantSnapshotRequestMessageC   s0    ;4>>;; "
--


 " "r   c                 .    | j                   j                  S r   )r.   ZoneSetLabelsRequestr   s    r   r"   z+_InstantSnapshot.GetSetLabelsRequestMessageG   s    >>...r   c           	         | j                   j                  } || j                  j                  | j                  j                  | j                  j
                  | j                   j                  |j                  |            S )NlabelFingerprintlabels)projectresourcezonezoneSetLabelsRequest)r.   'ComputeInstantSnapshotsSetLabelsRequestr+   rA   instantSnapshotrC   r<   r?   r   ipsr@   reqs       r   r$   z:_InstantSnapshot.GetSetInstantSnapshotLabelsRequestMessageJ   sk    
..
@
@C%%..]]!^^@@ 11& A B	C Cr   N
r	   r
   r   r   r*   classmethodr6   r   r"   r$   r   r   r   r(   r(   5   s.    H $ $"/Cr   r(   c                   8    e Zd ZdZd Zed        Zd Zd Zd Z	y)_RegionInstantSnapshotzEA wrapper for Compute Engine RegionInstantSnapshotService API client.c                 z    t         j                  |        || _        || _        |j                  | _        || _        y r   )r   r*   r+   r,   regionInstantSnapshotsr   r.   r/   s       r   r*   z_RegionInstantSnapshot.__init__W   s2    ##D)DMDL11DMDNr   c                      y)Nzcompute.regionOperationsr   r4   s    r   r6   z-_RegionInstantSnapshot.GetOperationCollection^   s    %r   c                 j     | j                   j                  di | j                  j                         S r8   )r.   'ComputeRegionInstantSnapshotsGetRequestr+   r:   r   s    r   r   z7_RegionInstantSnapshot.GetInstantSnapshotRequestMessageb   s0    A4>>AA "
--


 " "r   c                 .    | j                   j                  S r   )r.   RegionSetLabelsRequestr   s    r   r"   z1_RegionInstantSnapshot.GetSetLabelsRequestMessagef   s    >>000r   c           	         | j                   j                  } || j                  j                  | j                  j                  | j                  j
                  | j                   j                  |j                  |            S )Nr>   )rA   rB   regionregionSetLabelsRequest)r.   -ComputeRegionInstantSnapshotsSetLabelsRequestr+   rA   rF   rV   rT   r?   rG   s       r   r$   z@_RegionInstantSnapshot.GetSetInstantSnapshotLabelsRequestMessagei   sk    
..
F
FC%%..}}###~~DD 11&  E  B	C Cr   NrJ   r   r   r   rM   rM   T   s.    M & &"1Cr   rM   c                     | j                         dk(  ry| j                         dk(  ryt        dj                  | j                                     )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)r1   s    r   IsZonalr\   s   sU    ( 77??
=DD 	"# #r   c                 L    t        |       rt        || |      S t        || |      S )a8  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.
  )r\   r(   rM   )r1   r0   r2   s      r   GetInstantSnapshotInfor^      s*     WFGX66!&'8<<r   )r   
__future__r   r   r   r%   googlecloudsdk.core.exceptionsr   sixr   with_metaclassABCMetaobjectr   r(   rM   r\   r^   r   r   r   <module>re      ss    ` &  ' 
 0 
X5 X/S//VD .C- C>C3 C>#<=r   