
    H                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r
  SSKJr  SS	KJr  SS
KJr  SSKJr   " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)zUCommands for interacting with the Cloud NetApp Files Volume Replication API resource.    )absolute_import)division)unicode_literals)
list_pager)	constants)util)waiter)base)log)	resourcesc                       \ rS rSrSr\R                  R                  4S jr\	S 5       r
\	S 5       rS rS r      SS	 jrSS
 jrS rS rS r  SS jrS rS rS rS r SS jrS rS rSrg)ReplicationsClient   zKWrapper for working with Replications in the Cloud NetApp Files API Client.c                 l   U[         R                  R                  :X  a  [        5       U l        g U[         R                  R
                  :X  a  [        5       U l        g U[         R                  R                  :X  a  [        5       U l        g [        SR                  [        R                  U   5      5      e)Nz [{}] is not a valid API version.)r
   ReleaseTrackBETABetaReplicationsAdapter_adapterALPHAAlphaReplicationsAdapterGAReplicationsAdapter
ValueErrorformatnetapp_api_utilVERSION_MAP)selfrelease_tracks     @lib/googlecloudsdk/api_lib/netapp/volumes/replications/client.py__init__ReplicationsClient.__init__!   s    ))...-/dm	$++11	1.0dm	$++..	.)+dm
,
3
3))-8     c                 .    U R                   R                  $ N)r   clientr   s    r   r%   ReplicationsClient.client/   s    ==r"   c                 .    U R                   R                  $ r$   )r   messagesr&   s    r   r)   ReplicationsClient.messages3   s    ==!!!r"   c                     [         R                  " [         R                  " U R                  R                  5      USR                  UR                  5       5      5      $ )zWait on the long-running operation until the done field is True.

Args:
  operation_ref: the operation reference.

Raises:
  waiter.OperationError: if the operation contains an error.

Returns:
  the 'response' field of the Operation.
zWaiting for [{0}] to finish)r	   WaitForCloudOperationPollerNoResourcesr%   projects_locations_operationsr   Name)r   operation_refs     r   WaitForOperation#ReplicationsClient.WaitForOperation7   sL     >>..KK55	
 	%,,]-?-?-AB r"   c                 >   U R                   R                  UUR                  5       US9nU R                  R                  R                  U5      nU(       a  U$ [        R                  R                  UR                  [        R                  S9nU R                  U5      $ )z*Creates a Cloud NetApp Volume Replication.)parentreplicationIdreplication
collection)r)   7NetappProjectsLocationsVolumesReplicationsCreateRequestr/   r%   'projects_locations_volumes_replicationsCreater   REGISTRYParseRelativeNamenamer   OPERATIONS_COLLECTIONr1   )r   replication_ref
volume_refasync_configrequest	create_opr0   s           r   CreateReplication$ReplicationsClient.CreateReplicationK   s     	MM)..0 	N 	
  CCJJI &&889#B#B 9 M   //r"   Nc                     U R                   R                  5       nXl        X'l        X7l        XGl        U R                  R                  Xu5        Xgl        U$ )a  Parse the command line arguments for Create Replication into a config.

Args:
  name: the name of the Replication.
  description: the description of the Replication.
  labels: the parsed labels value.
  replication_schedule: the schedule for Replication.
  destination_volume_parameters: the input parameters used for creating
    destination volume.
  cluster_location: location of the user cluster, optional

Returns:
  the configuration that will be used as the request body for creating a
  Cloud NetApp Files Replication.
)	r)   Replicationr>   descriptionlabelsreplicationScheduler    ParseDestinationVolumeParametersclusterLocation)r   r>   rJ   rK   replication_scheduledestination_volume_parameterscluster_locationr6   s           r   ParseReplicationConfig)ReplicationsClient.ParseReplicationConfig^   sQ    0 --++-K)&:#MM22 #3r"   c                 b   U R                   R                  US9nU R                  R                  R	                  U5      nUR
                   H(  n[        R                  " SR                  U5      5        M*     [        R                  " U R                  R                  U[        R                  USS9$ )a_  List all active Cloud NetApp Volume Replications.

Args:
  volume_ref: The parent Volume to list NetApp Volume Replications.
  limit: The number of Cloud NetApp Volume Replications to limit the results
    to. This limit is passed to the server and the server does the limiting.

Returns:
  Generator that yields the Cloud NetApp Volume Replications.
)r4   zLocation {} may be unreachable.pageSize)fieldlimitbatch_size_attribute)r)   5NetappProjectsLocationsVolumesReplicationsListRequestr%   r:   Listunreachabler   warningr   r   YieldFromListr   REPLICATION_RESOURCE)r   rA   rW   rD   responselocations         r   ListReplications#ReplicationsClient.ListReplications   s     	KK 	L 	
  {{BBGGPH((	kk3::8DE )##;;,,' r"   c                 r    U R                   R                  UR                  5       S9nU R                  X#5      $ )z3Delete an existing Cloud NetApp Volume Replication.r>   )r)   7NetappProjectsLocationsVolumesReplicationsDeleteRequestRelativeName_DeleteReplication)r   r@   rB   rD   s       r   DeleteReplication$ReplicationsClient.DeleteReplication   s@     	MM --/ 	N 	
 
 ""633r"   c                     U R                   R                  R                  U5      nU(       a  U$ [        R                  R                  UR                  [        R                  S9nU R                  U5      $ )Nr7   )
r%   r:   Deleter   r<   r=   r>   r   r?   r1   )r   rB   rD   	delete_opr0   s        r   rg   %ReplicationsClient._DeleteReplication   sg    CCJJI &&889#B#B 9 M   //r"   c                     U R                   R                  UR                  5       S9nU R                  R                  R                  U5      $ )z5Get information of a Cloud NetApp Volume Replication.rd   )r)   4NetappProjectsLocationsVolumesReplicationsGetRequestrf   r%   r:   Get)r   r@   rD   s      r   GetReplication!ReplicationsClient.GetReplication   sJ     	JJ --/ 	K 	
 
 ;;>>BB7KKr"   c                 :    U R                   R                  XUUUS9$ )ar  Parse updates into a replication config.

Args:
  replication_config: The replication config to update.
  description: The new description, if any.
  labels: LabelsValue message, the new labels value, if any.
  replication_schedule: The new schedule for Replication, if any.
  cluster_location: location of the user cluster, if any.

Returns:
  The replication message.
)rJ   rK   rO   rQ   )r   ParseUpdatedReplicationConfigr   replication_configrJ   rK   rO   rQ   s         r   rt   0ReplicationsClient.ParseUpdatedReplicationConfig   s+      ==66F1) 7  r"   c                     U R                   R                  XU5      nU(       a  U$ [        R                  R	                  UR
                  [        R                  S9nU R                  U5      $ )aQ  Update a Cloud NetApp Volume Replication.

Args:
  replication_ref: the reference to the Replication.
  replication_config: Replication config, the updated replication.
  update_mask: str, a comma-separated list of updated fields.
  async_: bool, if False, wait for the operation to complete.

Returns:
  an Operation or Volume message.
r7   )	r   UpdateReplicationr   r<   r=   r>   r   r?   r1   )r   r@   rv   update_maskrB   	update_opr0   s          r   ry   $ReplicationsClient.UpdateReplication   se     //[I &&889#B#B 9 M   //r"   c                     U R                   R                  U5      nU(       a  U$ [        R                  R	                  UR
                  [        R                  S9nU R                  U5      $ )zResume a Cloud NetApp Volume Replication.

Args:
  replication_ref: the reference to the Replication.
  async_: bool, if False, wait for the operation to complete.

Returns:
  an Operation or Volume message.
r7   )	r   ResumeReplicationr   r<   r=   r>   r   r?   r1   )r   r@   rB   	resume_opr0   s        r   r~   $ReplicationsClient.ResumeReplication   s^     //@I&&889#B#B 9 M   //r"   c                     U R                   R                  U5      nU(       a  U$ [        R                  R	                  UR
                  [        R                  S9nU R                  U5      $ )a=  Reverse the direction of a Cloud NetApp Volume Replication.

Args:
  replication_ref: the reference to the Replication.
  async_: bool, if False, wait for the operation to complete.

Returns:
  an Operation if async_ is set to true, or a Replication message if the
  ReverseReplicationDirectionRequest is successful.
r7   )	r   ReverseReplicationr   r<   r=   r>   r   r?   r1   )r   r@   rB   
reverse_opr0   s        r   r   %ReplicationsClient.ReverseReplication   s^     11/BJ&&88I$C$C 9 M   //r"   c                     U R                   R                  X5      nU(       a  U$ [        R                  R	                  UR
                  [        R                  S9nU R                  U5      $ )a"  Stop a Cloud NetApp Volume Replication.

Args:
  replication_ref: the reference to the Replication.
  async_: bool, if False, wait for the operation to complete.
  force: bool, if True, call stop Replication with force parameter set to
    True.

Returns:
  an Operation or Volume message.
r7   )	r   StopReplicationr   r<   r=   r>   r   r?   r1   )r   r@   rB   forcestop_opr0   s         r   r   "ReplicationsClient.StopReplication  s]     mm++OCGn&&88!@!@ 9 M   //r"   c                 :    U R                   R                  XX45      $ )a  Parse the command line arguments for Establish Peering into a config.

Args:
  peer_cluster_name: the name of the peer cluster.
  peer_svm_name: the name of the peer svm.
  peer_volume_name: the name of the peer volume.
  peer_ip_addresses: the ip addresses of the peer cluster.

Returns:
  the configuration that will be used as the request body for establishing
  peering for Hybrid Replication.
)r   "ParseEstablishPeeringRequestConfig)r   peer_cluster_namepeer_svm_namepeer_volume_namepeer_ip_addressess        r   r   5ReplicationsClient.ParseEstablishPeeringRequestConfig%  s!    & ==;;*: r"   c                     U R                   R                  X5      nU(       a  U$ [        R                  R	                  UR
                  [        R                  S9nU R                  U5      $ )a9  Establish a peering for a Cloud NetApp Volume Replication.

Args:
  replication_ref: the reference to the Replication.
  establish_peering_request_config: the request configuration to establish
    peering.
  async_: bool, if False, wait for the operation to complete.

Returns:
  an Operation or Volume message.
r7   )	r   EstablishPeeringr   r<   r=   r>   r   r?   r1   )r   r@    establish_peering_request_configrB   establish_opr0   s         r   r   #ReplicationsClient.EstablishPeering<  se     ==11L &&88i&E&E 9 M   //r"   c                     U R                   R                  U5      nU(       a  U$ [        R                  R	                  UR
                  [        R                  S9nU R                  U5      $ )zSync a Cloud NetApp Volume Replication.

Args:
  replication_ref: the reference to the Replication.
  async_: bool, if False, wait for the operation to complete.

Returns:
  an Operation or Volume message.
r7   )	r   SyncReplicationr   r<   r=   r>   r   r?   r1   )r   r@   rB   sync_opr0   s        r   r   "ReplicationsClient.SyncReplicationT  s]     mm++O<Gn&&88!@!@ 9 M   //r"   )r   )NNNNNNr$   NNNN)__name__
__module____qualname____firstlineno____doc__r
   r   r   r    propertyr%   r)   r1   rF   rR   ra   rh   rg   rq   rt   ry   r~   r   r   r   r   r   __static_attributes__ r"   r   r   r      s    S#'#4#4#9#9      " "(0* $(!F84	0L :>26,000(0*02 .000r"   r   c                   \    \ rS rSrSrS rS rS r  SS jrS r	S	 r
S
 rS rS rS rSrg)r   ig  z<Adapter for the Cloud NetApp Files API Replication resource.c                     [         R                  R                  U l        [        R
                  " U R                  S9U l        [        R                  " U R                  S9U l        g N)r   )	r
   r   r   r   r   GetClientInstancer%   GetMessagesModuler)   r&   s    r   r    ReplicationsAdapter.__init__j  sN    **--D!33((DK $55((DMr"   c                    U(       d  gU R                   R                  5       nUR                  5        H  u  pEUS:X  a  XSl        M  US:X  a  XSl        M!  US:X  a  XSl        M/  US:X  a  XSl        M=  US:X  a'  U R                   R                  US   US   S	9Ul        Mj  [        R                  " S
R                  U5      5        M     X1l        g)a3  Parses Destination Volume Parameters for Replication into a config.

Args:
  replication: The Cloud Netapp Volumes Replication object.
  destination_volume_parameters: The Destination Volume Parameters message
    object.

Returns:
  Replication message populated with Destination Volume Parameters values.
Nstorage_pool	volume_id
share_namerJ   tiering_policyztier-actionzcooling-threshold-days)
tierActioncoolingThresholdDaysz#The attribute {} is not recognized.)r)   DestinationVolumeParametersitemsstoragePoolvolumeId	shareNamerJ   TieringPolicytieringPolicyr   r\   r   destinationVolumeParameters)r   r6   rP   
parameterskeyvals         r   rM   4ReplicationsAdapter.ParseDestinationVolumeParameterss  s     )::<J1779		!$+!,"-!$""#'==#>#>=)!$%=!> $? $

 
 	9@@EF :  /9+r"   c                     U R                   R                  UUR                  5       US9nU R                  R                  R                  U5      nU$ )z=Send a Patch request for the Cloud NetApp Volume Replication.)r6   r>   
updateMask)r)   6NetappProjectsLocationsVolumesReplicationsPatchRequestrf   r%   r:   Patch)r   r@   rv   rz   update_requestr{   s         r   ry   %ReplicationsAdapter.UpdateReplication  sZ     	LL* --/" 	M 	
  CCIII r"   Nc                 N    Ub  X!l         Ub  X1l        Ub  XAl        Ub  XQl        U$ )z=Parse update information into an updated Replication message.)rJ   rK   rL   rN   ru   s         r   rt   1ReplicationsAdapter.ParseUpdatedReplicationConfig  s:    
 '2$"('/C,#+;(r"   c                     U R                   R                  UR                  5       S9nU R                  R                  R                  U5      $ )z>Send a resume request for the Cloud NetApp Volume Replication.rd   )r)   7NetappProjectsLocationsVolumesReplicationsResumeRequestrf   r%   r:   Resume)r   r@   resume_requests      r   r~   %ReplicationsAdapter.ResumeReplication  sO     	MM --/ 	N 	
 
 ;;>>EE r"   c                     U R                   R                  UR                  5       S9nU R                  R                  R                  U5      $ )z?Send a reverse request for the Cloud NetApp Volume Replication.rd   )r)   ANetappProjectsLocationsVolumesReplicationsReverseDirectionRequestrf   r%   r:   ReverseDirection)r   r@   reverse_requests      r   r   &ReplicationsAdapter.ReverseReplication  sO     	WW --/ 	X 	
 
 ;;>>OO r"   c                     U R                   R                  UR                  5       U R                   R                  US9S9nU R                  R
                  R                  U5      $ )z<Send a stop request for the Cloud NetApp Volume Replication.)r   )r>   stopReplicationRequest)r)   5NetappProjectsLocationsVolumesReplicationsStopRequestrf   StopReplicationRequestr%   r:   Stop)r   r@   r   stop_requests       r   r   #ReplicationsAdapter.StopReplication  sj     	KK --/#'==#G#G $H $ 	L 	
  ;;>>CC r"   c                 P    U R                   R                  UUUU(       a  UO/ S9nU$ )zHParse establish peering request for the Cloud NetApp Volume Replication.)peerClusterNamepeerSvmNamepeerVolumeNamepeerIpAddresses)r)   EstablishPeeringRequest)r   r   r   r   r   establish_peering_requests         r   r   6ReplicationsAdapter.ParseEstablishPeeringRequestConfig  s8     !% E E)!'->)B	 !F ! %$r"   c                     U R                   R                  UR                  5       US9nU R                  R                  R                  U5      $ )zISend a establish peering request for the Cloud NetApp Volume Replication.)r>   establishPeeringRequest)r)   ANetappProjectsLocationsVolumesReplicationsEstablishPeeringRequestrf   r%   r:   r   )r   r@   r   r   s       r   r   $ReplicationsAdapter.EstablishPeering  sR     	WW --/$D 	X 	
  ;;>>OO! r"   c                     U R                   R                  UR                  5       S9nU R                  R                  R                  U5      $ )z<Send a sync request for the Cloud NetApp Volume Replication.rd   )r)   5NetappProjectsLocationsVolumesReplicationsSyncRequestrf   r%   r:   Sync)r   r@   sync_requests      r   r   #ReplicationsAdapter.SyncReplication  sO     	KK --/ 	L 	
 
 ;;>>CC r"   r%   r)   r   r   )r   r   r   r   r   r    rM   ry   rt   r~   r   r   r   r   r   r   r   r"   r   r   r   g  s@    D 9D :>26		% 
	r"   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  zAAdapter for the Beta Cloud NetApp Files API Replication resource.c                    > [         [        U ]  5         [        R                  R
                  U l        [        R                  " U R                  S9U l	        [        R                  " U R                  S9U l        g r   )superr   r    r
   r   r   r   r   r   r%   r   r)   r   	__class__s    r   r     BetaReplicationsAdapter.__init__  s]    	
!413**//D!33((DK $55((DMr"   r   r   r   r   r   r   r    r   __classcell__r   s   @r   r   r     s    I r"   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r   i  zBAdapter for the Alpha Cloud NetApp Files API Replication resource.c                    > [         [        U ]  5         [        R                  R
                  U l        [        R                  " U R                  S9U l	        [        R                  " U R                  S9U l        g r   )r   r   r    r
   r   r   r   r   r   r%   r   r)   r   s    r   r    !AlphaReplicationsAdapter.__init__  s]    	
"D24**00D!33((DK $55((DMr"   r   r   r   s   @r   r   r     s    J r"   r   N)r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.netappr   r   r   googlecloudsdk.api_lib.utilr	   googlecloudsdk.callioper
   googlecloudsdk.corer   r   objectr   r   r   r   r   r"   r   <module>r      sa    \ &  ' ' 3 A . ( # )F0 F0R
T& Tn1 6 r"   