
                         N   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mZ ddl	m
Z
 dd	lmZ dd
lmZ ddlmZ ej"                  j$                  diZej"                  j$                  fdZd Z G d dej,                        Z G d dej,                        Z G d de      Zy)z"Utilities for Transcoder API Jobs.    )absolute_import)division)unicode_literalsN)encoding)
list_pager)apis)base)util)labels_utilv1c                 X    t         j                  |       }t        j                  d|      S )N
transcoder)VERSION_MAPgetr   GetClientInstance)release_trackapi_versions     -lib/googlecloudsdk/api_lib/transcoder/jobs.py_GetClientInstancer   !   s#    .+			k	::    c                  .    t        j                  dd      S )z1Get a resource reference to the transcoder proto.r   r   )r   GetMessagesModule r   r   _GetTranscoderMessagesr   &   s    			d	33r   c                       e Zd ZdZdZy)ProcessingModePROCESSING_MODE_INTERACTIVEPROCESSING_MODE_BATCHN)__name__
__module____qualname__r   r   r   r   r   r   r   +   s     =1r   r   c                       e Zd ZdZdZy)OptimizationStrategy
AUTODETECTDISABLEDN)r   r    r!   r$   r%   r   r   r   r#   r#   0   s    *(r   r#   c                   ^    e Zd ZdZej
                  j                  dfdZd Zd Z	d Z
ddZy)	
JobsClientz-Client for job service in the Transcoder API.Nc                     |xs t        |      | _        | j                  j                  | _        | j                  j                  | _        | j                  j                  j                  | _        y )N)r   clientMESSAGES_MODULEmessageprojects_locations_jobs_serviceJob
_job_class)selfr   r)   s      r   __init__zJobsClient.__init__8   sM    =.}=DK;;..DLKK77DMkk1155DOr   c           	      H   t        j                  || j                  j                  j                        }|j
                  }|j                  }|j                  }d}|j                  /t               }|j                  j                  |j                        }d}	|j                  |j                  }	d}
|j                  /t               }|j                  j                  |j                        }
d}|*t        j                  |j                   |j"                        }|#| j                  j                  ||||||	|
      }nt%        j&                  | j(                  |      }|xs |j*                  |_        |xs |j,                  |_        |xs |j.                  |_        |xs |j                  |_        |
xs |j                  |_        |	xs |j0                  |_        | j                  j3                  |j5                         |      }| j6                  j9                  |      S )a  Create a job.

    Args:
      parent_ref: a Resource reference to a transcoder.projects.locations
        resource for the parent of this template.
      args: arguments to create a job.

    Returns:
      Job: Job created, including configuration and name.
    Nr   )inputUri	outputUri
templateIdlabelsmodebatchModePriorityoptimization)parentjob)r   ParseCreateArgsr+   r.   LabelsValue	input_uri
output_uritemplate_idr7   r   ModeValueValuesEnumbatch_mode_priorityr9   OptimizationValueValuesEnumr
   
GetContentfilejsonr   JsonToMessager/   r3   r4   r6   r8   ,TranscoderProjectsLocationsJobsCreateRequestRelativeNamer-   Create)r0   
parent_refargsr6   r>   r?   r@   r7   msgrB   r9   job_jsonr;   reqs                 r   rJ   zJobsClient.Create>   s    ((t||/?/?/K/KLFIJ""KDyy"$cWW((3d+ 44L$"$cWW889J9JKlHDII6hLL /#  c ""4??H=c.#,,cl 1CMMcm'SZZcj!ch%9)9)9c1JS5J5Jc
,,
C
C&&(c D C ==$$r   c                     | j                   j                  |j                               }| j                  j	                  |      S )zDelete a job.

    Args:
      job_ref: a resource reference to a transcoder.projects.locations.jobs
        resource to delete

    Returns:
      Empty: An empty response message.
    name)r+   ,TranscoderProjectsLocationsJobsDeleteRequestrI   r-   Deleter0   job_refrO   s      r   rT   zJobsClient.Deletet   sA     ,,
C
C!!# D C ==$$r   c                     | j                   j                  |j                               }| j                  j	                  |      S )zGet a job.

    Args:
      job_ref: a resource reference to a transcoder.projects.locations.jobs
        resource to get

    Returns:
      Job: if available, return the full job information.
    rQ   )r+   )TranscoderProjectsLocationsJobsGetRequestrI   r-   GetrU   s      r   rY   zJobsClient.Get   sA     ,,
@
@!!# A C ==S!!r   c                     | j                   j                  |j                         |      }t        j                  | j
                  ||dd      }|S )aO  List jobs.

    Args:
      parent_ref: a Resource reference to a transcoder.projects.locations
        resource to list job for.
      page_size (optional): the number of jobs to fetch in each request (affects
        requests made, but not the yielded results).

    Returns:
      Jobs: a list of jobs in the specified location
    )r:   pageSizejobsr[   )servicerequest
batch_sizefieldbatch_size_attribute)r+   *TranscoderProjectsLocationsJobsListRequestrI   r   YieldFromListr-   )r0   rK   	page_sizerO   resps        r   ListzJobsClient.List   sX     ,,
A
A&&(9 B C ##'D Kr   )d   )r   r    r!   __doc__r	   ReleaseTrackGAr1   rJ   rT   rY   rf   r   r   r   r'   r'   5   s0    5#'#4#4#7#7 64%l%"r   r'   )rh   
__future__r   r   r   enumapitools.base.pyr   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   %googlecloudsdk.command_lib.transcoderr
   $googlecloudsdk.command_lib.util.argsr   ri   rj   r   r   r   Enumr   r#   objectr'   r   r   r   <module>rt      s    ) &  '  % ' , ( 6 <  ##T* &*%6%6%9%9 ;
4
2TYY 2
499 
s sr   