
    R                     ~    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)Base client for Eventarc API interaction.    )absolute_import)division)unicode_literals)
exceptions)apis)waiter)	resourcesc                   .    e Zd ZdZd ZddZed        Zy)EventarcClientBasez1Base Client for interaction with of Eventarc API.c                 `    t        j                  ||      }|j                  | _        || _        y )N)r   GetClientInstanceprojects_locations_operations_operation_service_resource_label)selfapi_nameapi_versionresource_labelclients        +lib/googlecloudsdk/api_lib/eventarc/base.py__init__zEventarcClientBase.__init__   s*    ##Hk:F$BBD)D    c                    t        j                  | j                        }t        j                  j                  |j                  d      }|j                         }|j                         j                         j                         }|j                         j                         }	dj                  || j                  |||	      }
|rdj                  |
|      }
	 t        j                  |||
d      S # t        j                  $ rL}dj                  | j                  ||	      }d| j                  d	|d
}t        j                   ||      d}~ww xY w)a  Waits until the given long-running operation is complete.

    Args:
      operation: the long-running operation to wait for.
      operation_type: str, the type of operation (Creating, Updating or
        Deleting).
      resource_ref: Resource to reference.
      loading_msg: str, the message prompt to the user for a long-running
        operation.

    Returns:
      The long-running operation's response.

    Raises:
      HttpException: when failing to pull the long-running operation's status.
    z&eventarc.projects.locations.operations)
collectionz){} {} [{}] in project [{}], location [{}]z{}, {}i N  )wait_ceiling_msz,gcloud eventarc {} describe {} --location={}zFailed to poll status of the operation, but the operation may have succeeded. {status_message} After fixing the permission issue, either check the z by running `z!`, or rerun the original command.)error_formatN)r   CloudOperationPollerNoResourcesr   r	   REGISTRYParsenameNameParentformatr   WaitForapitools_exceptionsHttpForbiddenError_resource_label_pluralr   HttpException)r   	operationoperation_typeresource_refloading_msgpolleroperation_refresource_nameproject_namelocation_namemessageedesc_cmderror_messages                 r   r$   zEventarcClientBase.WaitFor$   s@   " 33D4K4KLF&&,,#K - MM %%'M&&(//1668L '')..0M &~t7K7K'4l'4!6  5gD^^
-%  11 
D?FF

%
%}mh +m $$Q]CC
Ds   C2 2EAEEc                 8    dj                  | j                        S )Nz{}s)r#   r   )r   s    r   r'   z)EventarcClientBase._resource_label_pluralQ   s    <<,,--r   N) )__name__
__module____qualname____doc__r   r$   propertyr'    r   r   r   r      s%    9*
+DZ . .r   r   N)r;   
__future__r   r   r   apitools.base.pyr   r%   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.corer	   objectr   r=   r   r   <module>rC      s.    0 &  ' > , 2 . )7. 7.r   