
                         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	)
z<Support library to handle the delivery-pipeline subcommands.    )absolute_import)division)unicode_literals)
list_pager)client_utilc                   .    e Zd ZdZddZd Z	 ddZd Zy)	DeliveryPipelinesClientz=Client for delivery pipeline service in the Cloud Deploy API.Nc                     |xs t        j                         | _        |xs t        j                  |      | _        | j                  j
                  | _        y)zInitialize a delivery_pipeline.DeliveryPipelinesClient.

    Args:
      client: base_api.BaseApiClient, the client class for Cloud Deploy.
      messages: module containing the definitions of messages for Cloud Deploy.
    N)r   GetClientInstanceclientGetMessagesModulemessages$projects_locations_deliveryPipelines_service)selfr   r   s      ;lib/googlecloudsdk/api_lib/clouddeploy/delivery_pipeline.py__init__z DeliveryPipelinesClient.__init__   sA     ;K99;DKE = =f EDMKKDDDM    c                 p    | j                   j                  |      }| j                  j                  |      S )zGets the delivery pipeline object by calling the delivery pipeline get API.

    Args:
      name: delivery pipeline name.

    Returns:
      a delivery pipeline object.
    )name)r   7ClouddeployProjectsLocationsDeliveryPipelinesGetRequestr   Get)r   r   requests      r   r   zDeliveryPipelinesClient.Get(   s;     	MM 	N 	
 
 ==W%%r   c                     | j                   j                  |||      }t        j                  | j                  |d||d      S )a  Lists Delivery Pipeline resources that belong to a location.

    Args:
      location: str, the full name of the location which owns the Delivery
        Pipelines.
      filter_str: optional[str], list filter.
      order_by: optional[str], field to sort by.
      page_size: optional[int], the maximum number of `DeliveryPipeline` objects
        to return.
      limit: int, The maximum number of records to yield. None if all available
        records should be yielded.

    Returns:
      Delivery Pipeline list response.
    )parentfilterorderBydeliveryPipelinespageSize)field
batch_sizelimitbatch_size_attribute)r   8ClouddeployProjectsLocationsDeliveryPipelinesListRequestr   YieldFromListr   )r   location
filter_strorder_by	page_sizer"   list_reqs          r   ListzDeliveryPipelinesClient.List8   sS    & 	NNJ 	O 	
 
 ##!' r   c                 r    | j                   j                  ||      }| j                  j                  |      S )zCreates a rollback for a given target.

    Args:
      name: pipeline name
      request: RollbackTargetRequest

    Returns:
      RollbackTargetResponse
    )r   rollbackTargetRequest)r   BClouddeployProjectsLocationsDeliveryPipelinesRollbackTargetRequestr   RollbackTarget)r   r   r   msgs       r   r/   z&DeliveryPipelinesClient.RollbackTargetX   s;     --
Z
Z% [ C =='',,r   )NN)NNr   N)__name__
__module____qualname____doc__r   r   r+   r/    r   r   r	   r	      s"    E	E&" JN@-r   r	   N)r4   
__future__r   r   r   apitools.base.pyr   "googlecloudsdk.api_lib.clouddeployr   objectr	   r5   r   r   <module>r:      s(    C &  ' ' :L-f L-r   