
                         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	)
z0Jobs client for Faultinjectiontesting Cloud SDK.    )absolute_import)division)unicode_literals)
list_pager)utilsc                   6    e Zd ZdZddZd Z	 	 d	dZd Zd Zy)

JobsClientz.Client for Jobs 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_jobs_jobs_client)selfr   r   s      2lib/googlecloudsdk/api_lib/fault_injection/jobs.py__init__zJobsClient.__init__   s>    =M;;=DKA ? ? ADM;;D    c                 p    | j                   j                  |      }| j                  j                  |      S )zDescribe a job in the Project/location.

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

    Returns:
      Described Job Resource.
    name)r   4FaultinjectiontestingProjectsLocationsJobsGetRequestr   Get)r   jobdescribe_reqs      r   DescribezJobsClient.Describe!   s=     	JJ 	K 	
 
   ..r   c                     | j                   j                  |      }t        j                  | j                  |d||d      S )aY  List Jobs 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 jobs.
    )parentjobspageSize)field
batch_sizelimitbatch_size_attribute)r   5FaultinjectiontestingProjectsLocationsJobsListRequestr   YieldFromListr   )r   r   r$   	page_sizelist_reqs        r   ListzJobsClient.List1   sQ    $ 	KK 	L 	
 
 ##' r   c                    g }|D ]-  }|j                  | j                  j                  |             / | j                  j                  ||      }| j                  j	                  ||||      }	| j
                  j                  |	      S )a2  Create a job in the Project/location.

    Args:
      job_id: str, the name for the job being created
      experiment_id: str, name of the experiment
      fault_targets: targets for the faults
      dry_run: Boolean value for dry-run
      parent: parent for fault resource

    Returns:
      Job.
    )service)
experimentfaultTargets)jobIdr   validateOnlyr   )appendr   FaultInjectionTargetMatcherJob7FaultinjectiontestingProjectsLocationsJobsCreateRequestr   Create)
r   job_idexperiment_idfault_targetsdry_runr   targetsfault_targetr   
create_reqs
             r   r5   zJobsClient.CreateP   s     G%nn
--
3
3L
3
I &
 --

}7

KCMM 	 	N 	
  ##J//r   c                 p    | j                   j                  |      }| j                  j                  |      S )zDelete a Job in the Project/location.

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

    Returns:
      Empty Response Message.
    r   )r   7FaultinjectiontestingProjectsLocationsJobsDeleteRequestr   Delete)r   r   
delete_reqs      r   r?   zJobsClient.Deletep   s=     	MM 	N 	
 
 ##J//r   )NN)Nd   )	__name__
__module____qualname____doc__r   r   r*   r5   r?    r   r   r	   r	      s'    6<
/& 	>0@0r   r	   N)rE   
__future__r   r   r   apitools.base.pyr   &googlecloudsdk.api_lib.fault_injectionr   r   objectr	   rF   r   r   <module>rK      s'    7 &  ' ' Ie0 e0r   