
                            S r SSKJrJrJr  SSKJr  SSKJr  SSKJ	r	  S\R                  S\	R                  R                  S\\   S	\\   4S
 jrS\R                  S\	R                  R                   S\4S jr      SS\R                  S\	R                  R                   S\\   S\\   S\\\\4      S\\\      S\\   S\\   4S jjr SS\R                  S\	R                  R                   S\4S jjrg)z&The BigQuery CLI model client library.    )DictListOptional)	discovery)bq_error)bq_id_utilsmodel_client	referencemax_results
page_tokenc                     U R                  5       R                  UR                  UR                  UUS9R	                  5       $ )a  Lists models for the given dataset reference.

Arguments:
  model_client: The apiclient used to make the request.
  reference: Reference to the dataset.
  max_results: Number of results to return.
  page_token: Token to retrieve the next page of results.

Returns:
  A dict that contains entries:
    'results': a list of models
    'token': nextPageToken for the last page, if present.
)	projectId	datasetId
maxResults	pageToken)modelslistr   r   execute)r	   r
   r   r   s       #platform/bq/clients/client_model.pylist_modelsr      sE    ( t'''' 	   wy	    returnc                 *   [         R                  " U[         R                  R                  SS9   U R	                  5       R                  UR                  UR                  UR                  S9R                  5       $ ! [        R                   a     gf = f)z!Returns true if the model exists.model_existsmethodr   r   modelIdF)r   	typecheckApiClientHelperModelReferencer   getr   r   r   r   r   BigqueryNotFoundError)r	   r
   s     r   r   r   +   s    
 !!00
	))))%% 
 


 
 
	'	' s   A
A; ;BBNdescription
expirationlabels_to_setlabel_keys_to_removevertex_ai_model_idetagc                    [         R                  " U[         R                  R                  SS9  0 nUb  X(S'   Ub  U=(       d    SUS'   SU;  a  0 US'   U(       a   UR	                  5        H  u  pXS   U	'   M     U(       a  U H  n	SUS   U	'   M     Ub  SU0/US'   U R                  5       R                  UUR                  UR                  UR                  S	9nU(       a  U(       a  UOUS
   UR                  S'   UR                  5         g)a  Updates a Model.

Args:
  model_client: The apiclient used to make the request.
  reference: the ModelReference to update.
  description: an optional description for model.
  expiration: optional expiration time in milliseconds since the epoch.
    Specifying 0 clears the expiration time for the model.
  labels_to_set: an optional dict of labels to set on this model.
  label_keys_to_remove: an optional list of label keys to remove from this
    model.
  vertex_ai_model_id: an optional string as Vertex AI model ID to register.
  etag: if set, checks that etag in the existing model matches.

Raises:
  BigqueryTypeError: if reference is not a ModelReference.
update_modelr   Nr$   expirationTimelabelsr(   trainingRuns)bodyr   r   r   r)   zIf-Match)r   r   r    r!   itemsr   patchr   r   r   headersr   )r	   r
   r$   r%   r&   r'   r(   r)   updated_model	label_keylabel_valuerequests               r   r+   r+   C   s!   6 !!00 -#.- &0&8DM"#]" M("/"5"5"7	+6Hi( #8)	+/mHi( *#&:<N%O$PM.!!''####	 ( ' 
*.$M&4IGOOJ	//r   ignore_not_foundc                 <   [         R                  " U[         R                  R                  SS9   U R	                  5       R                  UR                  UR                  UR                  S9R                  5         g! [        R                   a    U(       d  e  gf = f)ak  Deletes ModelReference reference.

Args:
  model_client: The apiclient used to make the request.
  reference: the ModelReference to delete.
  ignore_not_found: Whether to ignore "not found" errors.

Raises:
  BigqueryTypeError: if reference is not a ModelReference.
  bq_error.BigqueryNotFoundError: if reference does not exist and
    ignore_not_found is False.
delete_modelr   r   N)r   r   r    r!   r   deleter   r   r   r   r   r#   )r	   r
   r7   s      r   r9   r9      s    " !!00
  %%%%!! !  gi		'	'  s   AA< <BB)NNNNNN)F)__doc__typingr   r   r   googleapiclientr   utilsr   r   Resourcer    DatasetReferenceintstrr   r!   boolr   r+   r9    r   r   <module>rE      s_   , ' ' %  $$**;; # 	>$$**99 
6 "& $.204(,>$$>**99> #> 	>
 DcN+> #49-> !> 3->H #$$**99 r   