
    Z                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  S	rS
rSr\4S jr\S4S jrS rS rS rS\4S jrg)zKRM API Hosting API utilities.    )absolute_import)division)unicode_literals)encoding)apis)waiter)	resourcesv1i'  i@w c                 0    [         R                  " SU 5      $ )Nkrmapihosting)r   GetMessagesModule)api_versions    0lib/googlecloudsdk/api_lib/krmapihosting/util.pyr   r   #   s    				==    Tc                 6    [         R                  " SX(       + S9$ )zReturns an instance of the KRM API Hosting client.

Args:
  api_version: The desired api version.
  use_http: bool, True to create an http object for this client.

Returns:
  base_api.BaseApiClient, An instance of the Cloud Build client.
r   )no_http)r   GetClientInstance)r   use_https     r   r   r   '   s     
		{\
< <r   c                 ~    [        5       nUR                  nUR                  R                  UR	                  U S95      $ )a5  Fetches a KRMApiHost instance, and returns it as a messages.KrmApiHost.

Calls into the GetKrmApiHosts API.

Args:
  name: the fully qualified name of the instance, e.g.
    "projects/p/locations/l/krmApiHosts/k".

Returns:
  A messages.KrmApiHost.

Raises:
  HttpNotFoundError: if the instance didn't exist.
)name)r   MESSAGES_MODULEprojects_locations_krmApiHostsGet3KrmapihostingProjectsLocationsKrmApiHostsGetRequest)r   clientmessagess      r   GetKrmApiHostr   5   sC     &##(		.	.	2	2BBBM
O Or   c                     [        5       nUR                  nUR                  R                  UR	                  U S95      nUR
                  $ )zCalls into the ListKrmApiHosts API.

Args:
  parent: the fully qualified name of the parent, e.g.
    "projects/p/locations/l".

Returns:
  A list of messages.KrmApiHost.
)parent)r   r   r   List4KrmapihostingProjectsLocationsKrmApiHostsListRequestkrmApiHosts)r   r   r   resps       r   ListKrmApiHostsr$   J   sR     &##(		.	.	3	3CC D 
$ 
		r   c                     [        5       nUR                  nUR                  R                  UR	                  XUS95      $ )a  Creates a KRMApiHost instance, and returns the creation Operation.

Calls into the CreateKrmApiHost API.

Args:
  parent: the fully qualified name of the parent, e.g.
    "projects/p/locations/l".
  krm_api_host_id: the ID of the krmApiHost, e.g. "my-cluster" in
    "projects/p/locations/l/krmApiHosts/my-cluster".
  krm_api_host: a messages.KrmApiHost resource (containing properties like
    the bundle config)

Returns:
  A messages.OperationMetadata representing the long-running operation.
)r   
krmApiHostkrmApiHostId)r   r   r   Create6KrmapihostingProjectsLocationsKrmApiHostsCreateRequest)r   krm_api_host_idkrm_api_hostr   r   s        r   CreateKrmApiHostr,   \   sL      &##(		.	.	5	5EE F P
Q Qr   zWaiting for cluster to createc                 `   [        5       n[        R                  R                  U R                  SS9n[
        R                  " UR                  5      n[
        R                  " UUUU[        S9n[        R                  " U5      n[        5       n[        R                  " UR                  U5      $ )a_  Waits for the given "create" LRO to complete.

Args:
  operation: the operation to poll.
  progress_message: the message to display while waiting for the operation.
  max_wait_ms: number of ms to wait before raising TimeoutError.

Raises:
  apitools.base.py.HttpError: if the request returns an HTTP error.

Returns:
  A messages.KrmApiHost resource.
z+krmapihosting.projects.locations.operations)
collection)max_wait_mswait_ceiling_ms)r   r	   REGISTRYParseRelativeNamer   r   CloudOperationPollerNoResourcesprojects_locations_operationsWaitFor_WAIT_CEILING_MSr   MessageToJsonr   JsonToMessage
KrmApiHost)		operationprogress_messager/   r   operation_refpollerresultjsonr   s	            r    WaitForCreateKrmApiHostOperationr@   s   s    " &$$66nn!N 7 P-11**,&>>&(& 
			'$ (			 3 3T	::r   N)__doc__
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.corer	   _DEFAULT_API_VERSIONr6   _MAX_WAIT_TIME_MSr   r   r   r$   r,   r@    r   r   <module>rI      si    % &  ' % , . )    #  #7 > #7 <O*$Q2 5!;r   