
    w                         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	 Z G d
 de	j                        Zy)zUtilities for Insight.    )absolute_import)division)unicode_literals)encoding)
list_pager)base)
flag_utilsc                 B    t        j                  |       }t        |      S )zCreates Client.)r	   GetApiVersionInsight)release_trackapi_versions     1lib/googlecloudsdk/api_lib/recommender/insight.pyCreateClientr      s    ((7+		    c                   H     e Zd ZdZ fdZd Zd Zd	dZd Zd Z	d Z
 xZS )
r   z%Base Insight client for all versions.c                 b    t         t        |   |       | j                  j                  | _        y )N)superr   __init___client(projects_locations_insightTypes_insights_service)selfr   	__class__s     r   r   zInsight.__init__$   s#    	'4!+.LLIIDMr   c                 `   dj                  |      } | j                  |      |      }|r8t        j                  || j                  |      j                  d      }||_        d|t        j                  | j                  |z         |i} | j                  dj                  |            di |S )z-Creates MarkRequest with the specified state.zMarkInsight{}Request)etagT)
sort_itemsnamez=RecommenderProjectsLocationsInsightTypesInsightsMark{}Request )
format_GetVersionedMessager   DictToAdditionalPropertyMessageStateMetadataValuestateMetadatar	   ToCamelCase_message_prefix_GetMessage)	r   r   statestate_metadatar   request_namemark_requestmetadatakwargss	            r   _CreateMarkRequestzInsight._CreateMarkRequest(   s     *007L:4,,\:EL99


#
#L
1
D
Dh $,l  	t33lBC	F4GNN	  r   c                 p    | j                   j                  |      }| j                  j                  |      S )zGets an Insight.

    Args:
      name: str, the name of the insight being retrieved.

    Returns:
      The Insight message.
    )r   )	_messages:RecommenderProjectsLocationsInsightTypesInsightsGetRequestr   Get)r   r   requests      r   r2   zInsight.GetB   s6     nnWW X G==W%%r   c                     | j                   j                  ||      }t        j                  | j                  |d||d      S )a(  List Insights.

    Args:
      parent_name: str, the name of the parent.
      page_size: int, The number of items to retrieve per request.
      limit: int, The maximum number of records to yield.
      request_filter: str, Optional request filter

    Returns:
      The Insight messages.
    )parentfilterpageSizeinsights)batch_size_attribute
batch_sizelimitfield)r0   ;RecommenderProjectsLocationsInsightTypesInsightsListRequestr   YieldFromListr   )r   parent_name	page_sizer;   request_filterr3   s         r   ListzInsight.ListP   sN     nnXX> Y G ##' r   c                 `    | j                  |d||      }| j                  j                  |      S )a}  Mark an insight's state as ACCEPTED.

    Args:
      name: str, the name of the insight being updated.
      state_metadata: A map of metadata for the state, provided by user or
        automations systems.
      etag: Fingerprint of the Insight. Provides optimistic locking when
        updating states.

    Returns:
      The result insights after being marked as accepted
    Accepted)r.   r   MarkAccepted)r   r   r)   r   r3   s        r   rE   zInsight.MarkAcceptedh   s/     %%dJMG==%%g..r   c                 `    | j                  |dd|      }| j                  j                  |      S )a  Mark an insight's state as ACTIVE.

    Args:
      name: str, the name of the insight being updated.
      etag: Fingerprint of the Insight. Provides optimistic locking when
        updating states.

    Returns:
      The result insights after being marked as active
    ActiveN)r.   r   
MarkActiver   r   r   r3   s       r   rH   zInsight.MarkActivex   s/     %%dHdDAG==##G,,r   c                 `    | j                  |dd|      }| j                  j                  |      S )a  Mark an insight's state as DISMISSED.

    Args:
      name: str, the name of the insight being updated.
      etag: Fingerprint of the Insight. Provides optimistic locking when
        updating states.

    Returns:
      The result insights after being marked as dismissed
    	DismissedN)r.   r   MarkDismissedrI   s       r   rL   zInsight.MarkDismissed   s/     %%dKtDG==&&w//r   )NN)__name__
__module____qualname____doc__r   r.   r2   rB   rE   rH   rL   __classcell__)r   s   @r   r   r   !   s*    -J4&0/ -0r   r   N)rP   
__future__r   r   r   apitools.base.pyr   r   "googlecloudsdk.api_lib.recommenderr   r	   r   
ClientBaser   r   r   r   <module>rV      s6     &  ' % ' 3 9q0doo q0r   