o
    #j$                     @   sD   d Z ddlZddlmZ ddlmZ ddlmZ G dd deZdS )z
AIHC model client module.
    N)Optional)http_methods)AIHCBaseClientc                   @   s`   e Zd ZdZdddZdddZd	d
 Zdd Zdd ZdddZ	dd Z
dddZdd ZdS )ModelClientu   模型相关接口客户端N   
   c                 C   s@   d}d|d}|dur||d< |dur||d< | j tj||dS )u"  
        获取模型列表。

        参考文档：https://cloud.baidu.com/doc/AIHC/s/amc1fmz95

        :param keyword: 模型名称，用于筛选模糊匹配（可选，Query参数）
        :type keyword: str
        :param pageNumber: 分页参数，没传默认1（可选，Query参数）
        :type pageNumber: int
        :param pageSize: 分页大小，没传默认返回全部（可选，Query参数）
        :type pageSize: int
        :return: 模型列表及总数
        :rtype: baidubce.bce_response.BceResponse
           /DescribeModels)action
pageNumberNkeywordpageSizeparams_send_requestr   GET)selfr   r   r   pathr    r   r/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/baidubce/services/aihc/modules/model/model_client.pyr	      s   zModelClient.DescribeModelsc           
      C   sp   d}ddi}||d}	|dur||	d< |dur||	d< |dur#||	d< |dur+||	d	< | j tj|t|	|d
S )u  
        创建模型。

        参考文档：https://cloud.baidu.com/doc/AIHC/s/2mc1f9d4p

        :param name: 模型名称（必填，Body参数）
        :type name: str
        :param modelFormat: 模型格式（必填，Body参数）
        :type modelFormat: str
        :param description: 模型描述（可选，Body参数）
        :type description: str
        :param owner: 拥有者ID（可选，Body参数）
        :type owner: str
        :param visibilityScope: 可见范围（可选，Body参数）
        :type visibilityScope: str
        :param initVersionEntry: 初始版本信息（可选，Body参数，dict）
        :type initVersionEntry: dict
        :return: 创建结果
        :rtype: baidubce.bce_response.BceResponse
        r   r
   CreateModel)namemodelFormatNdescriptionownervisibilityScopeinitVersionEntrybodyr   r   r   POSTjsondumps)
r   r   r   r   r   r   r   r   r   r   r   r   r   r   8   s(   zModelClient.CreateModelc                 C       d}d|d}| j tj||dS )u(  
        删除模型，同时删除所有版本。

        参考文档：https://cloud.baidu.com/doc/AIHC/s/Mmc1fikgf

        :param modelId: 模型ID（必填，Query参数）
        :type modelId: str
        :return: 删除结果
        :rtype: baidubce.bce_response.BceResponse
        r   DeleteModelr
   modelIdr   r   r   r!   r   r'   r   r   r   r   r   r%   d      zModelClient.DeleteModelc                 C   s2   d}d|d}||d}| j tj|t||dS )u  
        修改模型。

        参考文档：https://cloud.baidu.com/doc/AIHC/s/hmc1fk2zd

        :param modelId: 模型ID（必填，Query参数）
        :type modelId: str
        :param name: 模型名称（必填，Body参数）
        :type name: str
        :param description: 描述（必填，Body参数）
        :type description: str
        :return: 修改结果
        :rtype: baidubce.bce_response.BceResponse
        r   ModifyModelr&   )r   r   r   r    )r   r'   r   r   r   r   r   r   r   r   r+   z   s   zModelClient.ModifyModelc                 C   r$   )u  
        获取模型详情。

        参考文档：https://cloud.baidu.com/doc/AIHC/s/Xmc1flhmc

        :param modelId: 模型ID（必填，Query参数）
        :type modelId: str
        :return: 模型详情
        :rtype: baidubce.bce_response.BceResponse
        r   DescribeModelr&   r   r   r)   r   r   r   r,      r*   zModelClient.DescribeModelc                 C   s$   d}d|||d}| j tj||dS )u  
        获取模型版本列表。

        参考文档：https://cloud.baidu.com/doc/AIHC/s/Lmc1fr4lc

        :param modelId: 模型ID（必填，Query参数）
        :type modelId: str
        :param pageNumber: 页码，默认1（可选，Query参数）
        :type pageNumber: int
        :param pageSize: 每页数量，默认10（可选，Query参数）
        :type pageSize: int
        :return: 模型版本列表及总数
        :rtype: baidubce.bce_response.BceResponse
        r   DescribeModelVersions)r
   r'   r   r   r   r   )r   r'   r   r   r   r   r   r   r   r-      s   z!ModelClient.DescribeModelVersionsc                 C   "   d}d||d}| j tj||dS )u  
        获取模型版本详情。

        参考文档：https://cloud.baidu.com/doc/AIHC/s/wmc1focnv

        :param modelId: 模型ID（必填，Query参数）
        :type modelId: str
        :param versionId: 模型版本ID（必填，Query参数）
        :type versionId: str
        :return: 模型版本详情
        :rtype: baidubce.bce_response.BceResponse
        r   DescribeModelVersionr
   r'   	versionIdr   r   r   r'   r1   r   r   r   r   r   r/         z ModelClient.DescribeModelVersionc           
      C   sT   d}d|d}|||d}	|dur||	d< |dur||	d< | j tj|t|	|dS )	u  
        新建模型版本。

        参考文档：https://cloud.baidu.com/doc/AIHC/s/imc1fsm39

        :param modelId: 模型ID（必填，Query参数）
        :type modelId: str
        :param storageBucket: 存储桶（必填，Body参数）
        :type storageBucket: str
        :param storagePath: 存储路径（必填，Body参数）
        :type storagePath: str
        :param source: 来源（必填，Body参数），如 UserUpload
        :type source: str
        :param description: 描述（可选，Body参数）
        :type description: str
        :param modelMetrics: 模型指标，JSON字符串（可选，Body参数）
        :type modelMetrics: str
        :return: 新建模型版本结果
        :rtype: baidubce.bce_response.BceResponse
        r   CreateModelVersionr&   )storageBucketstoragePathsourceNr   modelMetricsr   r    )
r   r'   r5   r6   r7   r   r8   r   r   r   r   r   r   r4      s$   zModelClient.CreateModelVersionc                 C   r.   )us  
        删除模型版本。

        参考文档：https://cloud.baidu.com/doc/AIHC/s/nmc1ftz7x

        :param modelId: 模型ID（必填，Query参数）
        :type modelId: str
        :param versionId: 模型版本ID（必填，Query参数）
        :type versionId: str
        :return: 删除结果
        :rtype: baidubce.bce_response.BceResponse
        r   DeleteModelVersionr0   r   r(   r2   r   r   r   r9     r3   zModelClient.DeleteModelVersion)Nr   r   )NNNN)r   r   )NN)__name__
__module____qualname____doc__r	   r   r%   r+   r,   r-   r/   r4   r9   r   r   r   r   r      s    

,

*r   )	r=   r"   typingr   Zbaidubce.httpr   Z,baidubce.services.aihc.base.aihc_base_clientr   r   r   r   r   r   <module>   s   