
    #                         d Z ddlmZ ddlmZ ddlmZ ddl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d Zd Zy)zDUtilities for AI Platform model deployment monitoring jobs commands.    )absolute_import)division)unicode_literalsN)	constants)errors)	resources)yaml)
console_ioc                 |    t         j                  j                  | t        j                        j                         S )N
collection)r   REGISTRYParser    MODEL_MONITORING_JOBS_COLLECTIONName)names    ?lib/googlecloudsdk/command_lib/ai/model_monitoring_jobs_util.pyParseJobNamer      s4    				!	!
yAA 
" 
CCG46J    c                 D   t        j                  | d      }t        j                  |      5 }	 t	        j
                  |      }t        |t              st        j                  d      |cddd       S # t        $ r t        j                  d      w xY w# 1 sw Y   yxY w)a~  Reads the instance from the given file path ('-' for stdin).

  Args:
    path: str or None, a path to a file ('-' for stdin) containing the JSON
      body.

  Returns:
    A instance.

  Raises:
    InvalidInstancesFileError: If the input file is invalid (invalid format or
        contains too many/zero instances), or an improper combination of input
        files was given.
  T)binaryzgInput instance are not in JSON format. See `gcloud ai model-monitoring-jobs create --help` for details.N)r
   ReadFromFileOrStdinioBytesIOr	   load
ValueErrorr   InvalidInstancesFileError
isinstancedict)pathdatafinstances       r   ReadInstanceFromArgsr$   #   s     
	'	'T	:$	zz$1N1h h%,,MN N    N,,MN NN s"   BA4&B4BBBc                     d| v r"	 t         j                  j                  | d      S t         j                  j                  | d      S # t         j                  $ r Y 6w xY w)zParse operation relative resource name to the operation reference object.

  Args:
    operation_name: The operation resource name

  Returns:
    The operation reference object
  z/modelDeploymentMonitoringJobs/zFaiplatform.projects.locations.modelDeploymentMonitoringJobs.operationsr   z(aiplatform.projects.locations.operations)r   r   ParseRelativeName WrongResourceCollectionException)operation_names    r   ParseMonitoringJobOperationr)   C   sw     '.811
] 2   
			-	-!K 
. 
M M 55 
s    A AA)__doc__
__future__r   r   r   r   googlecloudsdk.command_lib.air   r   googlecloudsdk.corer   r	   googlecloudsdk.core.consoler
   r   r$   r)    r   r   <module>r0      s8    K &  ' 	 3 0 ) $ 2J
@Mr   