
    q                         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 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 G d de      Zy)z+Utilities for Transcoder API Job Templates.    )absolute_import)division)unicode_literals)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     2lib/googlecloudsdk/api_lib/transcoder/templates.py_GetClientInstancer      s#    .+			k	::    c                   ^    e Zd ZdZej
                  j                  dfdZd Zd Z	d Z
ddZy)	TemplatesClientz2Client for template 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_jobTemplates_serviceJobTemplate_template_class)selfr   r   s      r   __init__zTemplatesClient.__init__'   sN    =.}=DK;;..DLKK??DM;;66BBDr   c                    t        j                  |j                  |j                        }t	        j
                  || j                  j                  j                        }t        j                  | j                  |      }|xs |j                  |_        | j                  j                  |j                         ||      }| j                  j!                  |      S )a9  Create a job template.

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

    Returns:
      JobTemplate: Template created
    )parentjobTemplateIdjobTemplate)r
   
GetContentfilejsonr   ParseCreateArgsr   r   LabelsValuer   JsonToMessager    labels4TranscoderProjectsLocationsJobTemplatesCreateRequestRelativeNamer   Create)r!   
parent_reftemplate_idargstemplate_jsonr-   job_templatereqs           r   r0   zTemplatesClient.Create-   s     OODIItyy9M(()-)A)A)M)MOF))$*>*>NL 7L$7$7L
,,
K
K&&(!  L "C
 ==$$r   c                     | j                   j                  |j                               }| j                  j	                  |      S )zDelete a job template.

    Args:
      template_ref: a resource reference to a
        transcoder.projects.locations.templates resource to delete

    Returns:
      Empty: An empty response message.
    name)r   4TranscoderProjectsLocationsJobTemplatesDeleteRequestr/   r   Deleter!   template_refr6   s      r   r;   zTemplatesClient.DeleteF   s?     ,,
K
K&&( L *C==$$r   c                     | j                   j                  |j                               }| j                  j	                  |      S )zGet a job template.

    Args:
      template_ref: a resource reference to a
        transcoder.projects.locations.templates resource to get

    Returns:
      JobTemplate: if available, return the full template information.
    r8   )r   1TranscoderProjectsLocationsJobTemplatesGetRequestr/   r   Getr<   s      r   r@   zTemplatesClient.GetT   s?     ,,
H
H&&( I *C==S!!r   c                     | j                   j                  |j                         |      }t        j                  | j
                  ||dd      }|S )ay  List jobs templates.

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

    Returns:
      JobTemplates: a list of job templates in the specified location
    )r$   pageSizejobTemplatesrB   )servicerequest
batch_sizefieldbatch_size_attribute)r   2TranscoderProjectsLocationsJobTemplatesListRequestr/   r   YieldFromListr   )r!   r1   	page_sizer6   resps        r   ListzTemplatesClient.Listb   sV     ,,
I
I&&(9 J >C##')D Kr   )d   )__name__
__module____qualname____doc__r	   ReleaseTrackGAr"   r0   r;   r@   rM    r   r   r   r   $   s0    :#'#4#4#7#7 C%2%"r   r   N)rR   
__future__r   r   r   apitools.base.pyr   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   %googlecloudsdk.command_lib.transcoderr
   $googlecloudsdk.command_lib.util.argsr   rS   rT   r   r   objectr   rU   r   r   <module>r]      s_    2 &  ' % ' , ( 6 <  ##T* &*%6%6%9%9 ;
Rf Rr   