
    	                         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\R                  5      r
S	 r " S
 S\5      rg)z)Utilities for dealing with ML models API.    )
list_pager)apis)
exceptions)
properties)	resourcesc                       \ rS rSrSrSrg)NoFieldsSpecifiedError   zEError indicating that no updates were requested in a Patch operation. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       .lib/googlecloudsdk/api_lib/ml_engine/models.pyr	   r	      s    Mr   r	   c                     [         R                  R                  U S[        R                  R
                  R                  R                  0SS9$ )N
projectsIdzml.projects.models)params
collection)r   REGISTRYParser   VALUEScoreproject	GetOrFail)model_ids    r   _ParseModelr      sF    				!	!J--22::DDE% 
" 
' 'r   c                   X    \ rS rSrSrSS jr  SS jrS rS rS r	S	 r
S
 rSS jrSrg)ModelsClient$   z,High-level client for the ML models surface.Nc                     U=(       d    [         R                  " SS5      U l        U=(       d    U R                  R                  U l        g )Nmlv1)r   GetClientInstanceclientMESSAGES_MODULEmessages)selfr'   r)   s      r   __init__ModelsClient.__init__'   s1    >D224>DK; ; ;DMr   c                 l   [        U5      nU=(       d    / n[        R                  R                  UR                  SS9n	U R
                  R                  U	R                  5       U R
                  R                  UR                  5       UUUUUS9S9n
U R                  R                  R                  U
5      $ )zCreate a new model.zml.projects)r   )nameregionsonlinePredictionLoggingonlinePredictionConsoleLoggingdescriptionlabels)parentgoogleCloudMlV1Model)r   r   r   r   r   r)   MlProjectsModelsCreateRequestRelativeNameGoogleCloudMlV1ModelNamer'   projects_modelsCreate)r*   
model_namer/   enable_loggingenable_console_loggingr3   r2   	model_refregions_listproject_refreqs              r   r;   ModelsClient.Create+   s     J'I=bL$$**9+?+?6C + EK
--
5
5'')!]]??! $2+A# @  6 C ;;&&--c22r   c                     U R                   R                  R                  U R                  R	                  UR                  5       S95      $ )N)resource)r'   r:   GetIamPolicyr)   #MlProjectsModelsGetIamPolicyRequestr7   )r*   r?   s     r   rF   ModelsClient.GetIamPolicy=   sB    ;;&&3399++- 	: 	/0 0r   c                     U R                   R                  UUS9nU R                  R                  R	                  U R                   R                  UUR                  5       S95      $ )N)policy
updateMask)googleIamV1SetIamPolicyRequestrE   )r)   GoogleIamV1SetIamPolicyRequestr'   r:   SetIamPolicy#MlProjectsModelsSetIamPolicyRequestr7   )r*   r?   rJ   update_maskrequests        r   rN   ModelsClient.SetIamPolicyB   sf    mm:: ;  G ;;&&3399+2++- 	: 	/0 0r   c                     [        U5      nU R                  R                  UR                  5       S9nU R                  R
                  R                  U5      $ )zDelete an existing model.r.   )r   r)   MlProjectsModelsDeleteRequestr7   r'   r:   Deleter*   modelr?   rB   s       r   rV   ModelsClient.DeleteK   sL    E"I
--
5
5##% 6 'C;;&&--c22r   c                     [        U5      nU R                  R                  UR                  5       S9nU R                  R
                  R                  U5      $ )zGet details about a model.rT   )r   r)   MlProjectsModelsGetRequestr7   r'   r:   GetrW   s       r   r\   ModelsClient.GetR   sL    E"I
--
2
2##% 3 'C;;&&**3//r   c                     U R                   R                  UR                  5       S9n[        R                  " U R
                  R                  USSS9$ )zList models in the project.)r4   modelspageSize)fieldbatch_size_attribute)r)   MlProjectsModelsListRequestr7   r   YieldFromListr'   r:   )r*   rA   rB   s      r   ListModelsClient.ListY   sP    
--
3
3'') 4 +C####'	) )r   c                    U R                   R                  5       n/ nUR                  (       a"  UR                  Ul        UR	                  S5        U(       a  X4l        UR	                  S5        U(       d  [        S5      eU R                   R                  UR                  5       USR                  U5      S9nU R                  R                  R                  U5      $ )zUpdate a model.r3   r2   zNo updates requested.,)r.   r5   rK   )r)   r8   needs_updater3   appendr2   r	   MlProjectsModelsPatchRequestr7   joinr'   r:   Patch)r*   r?   labels_updater2   rX   rP   rB   s          r   rm   ModelsClient.Patchc   s    MM..0EK!!"))el"%'"#:;;
--
4
4##%"88K( 5 *C ;;&&,,S11r   )r'   r)   )NN)FFNN)N)r   r   r   r   r   r+   r;   rF   rN   rV   r\   re   rm   r   r   r   r   r!   r!   $   s5    4< 8=DH3$0
030)2r   r!   N)r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r   r   Errorr	   r   objectr!   r   r   r   <module>ru      sB    0 ( , * * )NZ-- N'R26 R2r   