
    '                     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	)
z1Fault client for Faultinjectiontesting Cloud SDK.    )absolute_import)division)unicode_literals)
list_pager)utilsc                   <    e Zd ZdZd	dZd Zd Zd Zd Z	 	 d
dZ	y)FaultsClientz0Client for faults in Faultinjection Testing API.Nc                     |xs t        j                         | _        |xs t        j                         | _        | j                  j
                  | _        y )N)api_lib_utilsGetClientInstanceclientGetMessagesModulemessagesprojects_locations_faults_faults_client)selfr   r   s      4lib/googlecloudsdk/api_lib/fault_injection/faults.py__init__zFaultsClient.__init__   s>    =M;;=DKA ? ? ADM++??D    c                 p    | j                   j                  |      }| j                  j                  |      S )zDescribe a Fault in the Project/location.

    Args:
      fault: str, the name for the fault being described.

    Returns:
      Described Fault Resource.
    name)r   6FaultinjectiontestingProjectsLocationsFaultsGetRequestr   Get)r   faultdescribe_reqs      r   DescribezFaultsClient.Describe!   s=     	LL 	M 	
 
 ""<00r   c                 p    | j                   j                  |      }| j                  j                  |      S )zDelete a fault in the Project/location.

    Args:
      fault: str, the name for the fault being deleted

    Returns:
      Empty Response Message.
    r   )r   9FaultinjectiontestingProjectsLocationsFaultsDeleteRequestr   Delete)r   r   
delete_reqs      r   r    zFaultsClient.Delete1   s=     	OO 	P 	
 
 %%j11r   c                 f    t        j                  |||      }| j                  j                  |      S )zCreate a fault in the Project/location.

    Args:
      fault: str, the name for the fault being created
      faultconfig: file, the file which contains fault config
      parent: parent for fault resource

    Returns:
      Fault.
    )r   ParseCreateFaultFromYamlr   Create)r   r   faultconfigparent
create_reqs        r   r$   zFaultsClient.CreateA   s4      88{F
J %%j11r   c                 d    t        j                  ||      }| j                  j                  |      S )zUpdate a fault in the Project/location.

    Args:
      fault: str, the name for the fault being created
      faultconfig: file, the file which contains fault config

    Returns:
      Fault.
    )r   ParseUpdateFaultFromYamlr   Patch)r   r   r%   	patch_reqs       r   UpdatezFaultsClient.UpdateR   s-     77{KI$$Y//r   c                     | j                   j                  |      }t        j                  | j                  |d||d      S )a]  List Faults in the Projects/Location.

    Args:
      parent: str, projects/{projectId}/locations/{location}
      limit: int or None, the total number of results to return.
      page_size: int, the number of entries in each batch (affects requests
        made, but not the yielded results).

    Returns:
      Generator of matching Faults.
    )r&   faultspageSize)field
batch_sizelimitbatch_size_attribute)r   7FaultinjectiontestingProjectsLocationsFaultsListRequestr   YieldFromListr   )r   r&   r2   	page_sizelist_reqs        r   ListzFaultsClient.List`   sQ    $ 	MM 	N 	
 
 ##' r   )NN)Nd   )
__name__
__module____qualname____doc__r   r   r    r$   r,   r8    r   r   r	   r	      s,    8@
1 2 2"0" 	r   r	   N)r=   
__future__r   r   r   apitools.base.pyr   &googlecloudsdk.api_lib.fault_injectionr   r   objectr	   r>   r   r   <module>rC      s'    8 &  ' ' Id6 dr   