
    p                     R    d Z ddlmZ ddlmZ ddlmZ ddlmZ dZ G d de      Z	y	)
z1Support library to handle the target subcommands.    )absolute_import)division)unicode_literals)client_utilz*,labelsc                   0    e Zd ZdZddZd Zd Zd Zd Zy)	TargetsClientz2Client for target service in the Cloud Deploy API.Nc                     |xs t        j                         | _        |xs t        j                  |      | _        | j                  j
                  | _        y)zInitialize a target.TargetClient.

    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_targets_service)selfr   r   s      0lib/googlecloudsdk/api_lib/clouddeploy/target.py__init__zTargetsClient.__init__   sA     ;K99;DKE = =f EDMKK::DM    c                 p    | j                   j                  |      }| j                  j                  |      S )zGets the shared target object by calling the ProjectsLocationsTargetsService.Get API.

    Args:
      name: str, target name.

    Returns:
      a target object.
    )name)r   -ClouddeployProjectsLocationsTargetsGetRequestr   Get)r   r   requests      r   r   zTargetsClient.Get(   s6     mmII J G==W%%r   c                     | j                   j                  | j                  j                  |d|j                  t
                    S )zPatches a target resource.

    Args:
      target_obj: apitools.base.protorpclite.messages.Message, target message.

    Returns:
      The operation message.
    T)targetallowMissingr   
updateMask)r   Patchr   /ClouddeployProjectsLocationsTargetsPatchRequestr   TARGET_UPDATE_MASK)r   
target_objs     r   r   zTargetsClient.Patch5   sC     ==EE)	 	F 	+, ,r   c                 n    | j                   j                  | j                  j                  d|            S )zDeletes a target resource.

    Args:

      name: str, target name.

    Returns:
      The operation message. It could be none if the resource doesn't exist.
    T)r   r   )r   Deleter   0ClouddeployProjectsLocationsTargetsDeleteRequest)r   r   s     r   r"   zTargetsClient.DeleteE   s8     ==FFD 	G 	*+ +r   c                 l    | j                   j                  | j                  j                  |            S )zLists target resources in a location.

    Args:
      location: str, the full name of the location which owns the targets.

    Returns:
      Returns a list of targets in the given location.
    )parent)r   Listr   .ClouddeployProjectsLocationsTargetsListRequest)r   locations     r   r&   zTargetsClient.ListS   s6     ==DD 	E 	 r   )NN)	__name__
__module____qualname____doc__r   r   r   r"   r&    r   r   r   r      s    :	;&, +r   r   N)
r,   
__future__r   r   r   "googlecloudsdk.api_lib.clouddeployr   r   objectr   r-   r   r   <module>r1      s*    8 &  ' : DF Dr   