
    ^                     Z    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ  G d de      Z	y	)
zPacket mirroring.    )absolute_import)division)unicode_literals)
exceptions)logc                   ~    e Zd ZdZddZed        Zed        Zd Z	 	 	 ddZ	d Z
	 	 	 	 dd	Zd
 ZddZd ZddZy)PacketMirroringz#Abstracts PacketMirroring resource.Nc                 .    || _         || _        || _        y N)ref_compute_client	_registry)selfr   compute_clientregistrys       Blib/googlecloudsdk/command_lib/compute/packet_mirrorings/client.py__init__zPacketMirroring.__init__   s    DH)DDN    c                 .    | j                   j                  S r   )r   apitools_clientr   s    r   _clientzPacketMirroring._client!   s    ///r   c                 .    | j                   j                  S r   )r   messagesr   s    r   	_messageszPacketMirroring._messages%   s    (((r   c                     | j                   j                  d| j                  j                  | j                  j
                  | j                  j                  |      fS )NInsert)projectregionpacketMirroring)r   packetMirroringsr   $ComputePacketMirroringsInsertRequestr   r   r   r   packet_mirrorings     r   _MakeCreateRequestTuplez'PacketMirroring._MakeCreateRequestTuple)   sN    LL))8NN??((xx 0 @ 23 3r   c                    | j                  |      g}|r|S |s| j                  j                  |      S g }| j                  j                  ||      d   }|rt	        j
                  |      | j                  j                  |j                  d| j                  j                  | j                  j                  dd      }t        j                  |dj                  | j                  j                               dd	       |S )
z.Sends requests to create the packet mirroring.r   compute.regionOperationsr   r   v1
collectionparamsapi_versionpacket mirroring [{0}]T[Run the [gcloud compute operations describe] command to check the status of this operation.kindis_asyncdetails)r%   r   MakeRequestsAsyncRequestsr   
MultiErrorr   Parsenamer   r   r   r   CreatedResourceformatName)r   r$   only_generate_requestr2   requestserrors_to_collectresultoperation_refs           r   CreatezPacketMirroring.Create0   s    
 ,,-=>?Ho!!..x88!!//:KLQOF!!"344NN((-xx''hhoo
  ) M %,,TXX]]_=1	2 Mr   c                     | j                   j                  d| j                  j                  | j                  j
                  | j                  j                  | j                  j                         |      fS )NPatch)r   r   r    packetMirroringResource)r   r!   r   #ComputePacketMirroringsPatchRequestr   r   r   r;   r#   s     r   _MakeUpdateRequestTuplez'PacketMirroring._MakeUpdateRequestTupleS   sZ    LL))7NN>>((xx $(8	 ? :; ;r   c                 ~   | j                  |      g}|r|S g }| j                  j                  |xs g       5  |s$| j                  j	                  |      cddd       S | j                  j                  ||      d   }ddd       |rt        j                  |      | j                  j                  j                  d| j                  j                  | j                  j                  dd      }t        j                  |dj!                  | j                  j#                               dd	
       |S # 1 sw Y   xY w)z.Sends requests to update the packet mirroring.Nr   r'   r(   r)   r*   r.   Tr/   r0   )rF   r   IncludeFieldsr   r4   BatchRequestsr   r6   r   r7   r8   r   r   r   r   UpdatedResourcer:   r;   )	r   r$   r<   r2   cleared_fieldsr=   r>   r?   r@   s	            r   UpdatezPacketMirroring.Update[   s'    ,,-=>?Ho		#	#N$8b	9##00: 
:	9 ##11(2CEEFHf 
: !!"344NN((-xx''hhoo
  ) M %,,TXX]]_=1	2 M/ 
:	9s   D3D33D<c                     | j                   j                  d| j                  j                  | j                  j
                  | j                  j                  | j                  j                               fS )NDeleter   r   r    )r   r!   r   $ComputePacketMirroringsDeleteRequestr   r   r   r;   r   s    r   MakeDeleteRequestTuplez&PacketMirroring.MakeDeleteRequestTuple   sX    LL))8NN??xx(( $ @ 12 2r   c                 b    | j                         g}|s| j                  j                  |      S |S r   )rQ   r   r4   r   r<   r=   s      r   rN   zPacketMirroring.Delete   s2    ++-.H !!..x88Or   c                     | j                   j                  d| j                  j                  | j                  j
                  | j                  j                  | j                  j                               fS )NGetrO   )r   r!   r   !ComputePacketMirroringsGetRequestr   r   r   r;   r   s    r   _MakeDescribeRequestTuplez)PacketMirroring._MakeDescribeRequestTuple   sW    LL))5NN<<xx(( $ = 12 2r   c                 b    | j                         g}|s| j                  j                  |      S |S r   )rW   r   r4   rS   s      r   DescribezPacketMirroring.Describe   s2    ..01H !!..x88Or   )NN)NFF)NFFN)F)__name__
__module____qualname____doc__r   propertyr   r   r%   rA   rF   rL   rQ   rN   rW   rY    r   r   r	   r	      su    +
 0 0 ) )3 ##(!F; ##( 	$L22r   r	   N)
r]   
__future__r   r   r   googlecloudsdk.corer   r   objectr	   r_   r   r   <module>rc      s'     &  ' * #@f @r   