
    M                     ~    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  G d
 de      Zy)zApphub Service Projects API.    )absolute_import)division)unicode_literals)
list_pager)consts)utils)waiter)basec                   l    e Zd ZdZej
                  j                  fdZd Z	 	 d
dZ	d Z
d Zd Zd	 Zy)ServiceProjectsClientz*Client for service projects in apphub API.c                    t        j                  |      | _        t        j                  |      | _        | j                  j
                  | _        | j                  j                  | _        t        j                  | j                  | j                  j                        | _        t        j                  | j                  j                        | _        y )N)api_lib_utilsGetClientInstanceclientGetMessagesModulemessages,projects_locations_serviceProjectAttachments
_sp_clientprojects_locations_project_locations_clientr	   CloudOperationPollerprojects_locations_operations_pollerCloudOperationPollerNoResources_remove_poller)selfrelease_tracks     5lib/googlecloudsdk/api_lib/apphub/service_projects.py__init__zServiceProjectsClient.__init__   s    11-@DK!33MBDMkkNNDO%)[[%C%CD"..11DL !@@11D    c                 p    | j                   j                  |      }| j                  j                  |      S )zDescribe a service project in the Project/location.

    Args:
      service_project: str, the name for the service project being described.

    Returns:
      Described service project Resource.
    name)r   :ApphubProjectsLocationsServiceProjectAttachmentsGetRequestr   Get)r   service_projectdescribe_reqs      r   DescribezServiceProjectsClient.Describe,   s8     ==[[ \ L ??|,,r    Nc                     | j                   j                  |      }t        j                  | j                  |d||d      S )a  List service projects in the Projects/Location.

    Args:
      parent: str, projects/{projectId}/locations/{location}
      limit: int or None, the total number of results to return.
        Default value is None
      page_size: int, the number of entries in each batch (affects requests
        made, but not the yielded results). Default value is 100.

    Returns:
      Generator of matching service projects.
    )parentserviceProjectAttachmentspageSize)field
batch_sizelimitbatch_size_attribute)r   ;ApphubProjectsLocationsServiceProjectAttachmentsListRequestr   YieldFromListr   )r   r*   r/   	page_sizelist_reqs        r   ListzServiceProjectsClient.List:   sO    & 	QQ 	R 	
 
 ##)' r    c                 b   | j                   j                  d|z         }| j                   j                  |||      }| j                  j	                  |      }|r|S t        j                  | j                  |t        j                  j                  t        j                  j                        }|S )ah  Add a service project in the Project/location.

    Args:
      service_project: str, the name for the service project being created
      async_flag: Boolean value for async operation. If true the operation will
        be async
      parent: parent for service project resource

    Returns:
      Service Project or Operation based on async flag value.
    	projects/)serviceProject)r*   serviceProjectAttachmentserviceProjectAttachmentId)r   ServiceProjectAttachment=ApphubProjectsLocationsServiceProjectAttachmentsCreateRequestr   Creater   WaitForOperationr   api_lib_constsAddServiceProjectWAIT_FOR_ADD_MESSAGEADD_TIMELIMIT_SEC)r   r&   
async_flagr*   service_project_attachment
create_req	operationcreate_responses           r   AddzServiceProjectsClient.AddZ   s    $ "&!G!G"_4 "H " \\!;#2 ] J
 &&z2I#44((==((::	O r    c                     | j                   j                  |      }| j                  j                  |      }|r|S t	        j
                  | j                  |t        j                  j                  t        j                  j                        }|S )a@  Remove a service project in the Project/location.

    Args:
      service_project: str, the name for the service project being deleted
      async_flag: Boolean value for async operation. If true the operation will
        be async

    Returns:
      Empty Response Message or Operation based on async flag value.
    r"   )r   =ApphubProjectsLocationsServiceProjectAttachmentsDeleteRequestr   Deleter   r>   r   r?   RemoveServiceProjectWAIT_FOR_REMOVE_MESSAGEREMOVE_TIMELIMIT_SEC)r   r&   rC   
remove_reqrF   remove_responses         r   RemovezServiceProjectsClient.Remove   s     \\ ] J &&z2I#44++CC++@@	O r    c                 |    | j                   j                  d|z   dz         }| j                  j                  |      S )zLookup a service project in the Project/location.

    Args:
      service_project: Service project id

    Returns:
       Service Project.
    r7   /locations/globalr"   )r   <ApphubProjectsLocationsLookupServiceProjectAttachmentRequestr   LookupServiceProjectAttachment)r   r&   
lookup_reqs      r   LookupzServiceProjectsClient.Lookup   sJ     [[?*-@@ \ J ))HH r    c                 |    | j                   j                  d|z   dz         }| j                  j                  |      S )zDetach a service project in the Project/location.

    Args:
      service_project: Service project id

    Returns:
      None
    r7   rS   r"   )r   <ApphubProjectsLocationsDetachServiceProjectAttachmentRequestr   DetachServiceProjectAttachment)r   r&   
detach_reqs      r   DetachzServiceProjectsClient.Detach   sJ     [[?*-@@ \ J ))HH r    )Nd   )__name__
__module____qualname____doc__r
   ReleaseTrackALPHAr   r(   r5   rH   rQ   rW   r\    r    r   r   r      sA    2#'#4#4#:#: -" 	@'R8"r    r   N)ra   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.apphubr   r?   r   r   googlecloudsdk.api_lib.utilr	   googlecloudsdk.callioper
   objectr   rd   r    r   <module>rk      s0    # &  ' ' B @ . (bF br    