o
    lqi -                     @   s   d Z G dd deZdd ZG dd deZdd ZG d	d
 d
eZdd ZG dd deZG dd deZ	G dd deZ
G dd deZG dd deZdd ZG dd deZdd ZG dd deZdd  Zd!S )"z3
This module defines some Argument classes for BTS
c                   @   s   e Zd ZdZdddZdS )CreateInstanceArgsz
    Create Instance Args
    :param storage_type  instance's storage type. eg.CommonPerformance
    :type storage_type string
    Nc                 C   
   || _ d S Nstorage_type)selfr    r   b/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/baidubce/services/bts/model.py__init__      
zCreateInstanceArgs.__init__r   __name__
__module____qualname____doc__r	   r   r   r   r   r      s    r   c                 C   
   d| j iS )z
    change create_instance_args to dict

    :param args: create instance args
    :type args: CreateInstanceArgs

    :return:
    :rtype dict
    storageTyper   argsr   r   r   create_instance_args_2_dict   s   r   c                   @   s   e Zd ZdZdddZdS )CreateTableArgsa  
    Create Table Args
    :param table_version  table's version
    :type table_version int64
    :param compress_type  table's compress type. eg.SNAPPY_ALL
    :type compress_type string
    :param ttl  time to live
    :type ttl int
    :param storage_type  instance's storage type. eg.CommonPerformance
    :type storage_type string
    :param max_versions  table's max data versions.
    :type max_versions int
        N   c                 C   s"   || _ || _|| _|| _|| _d S r   table_versioncompress_typettlr   max_versions)r   r   r   r   r   r   r   r   r   r	   8   s
   
zCreateTableArgs.__init__)r   Nr   Nr   r   r   r   r   r   r   *   s    r   c                 C   s   | j | j| j| j| jdS )z
    change create_table_args to dict

    :param args: create table args
    :type args: CreateTableArgs

    :return:
    :rtype dict
    )tableVersioncompressTyper   r   maxVersionsr   r   r   r   r   create_table_args_2_dict@   s   r    c                   @   s   e Zd ZdZdddZdS )UpdateTableArgsa>  
    Update Table Args
    :param table_version  table's version
    :type table_version int64
    :param compress_type  table's compress type. eg.SNAPPY_ALL
    :type compress_type string
    :param ttl time to live
    :type ttl int
    :param max_versions  table's max data versions.
    :type max_versions int
    r   Nc                 C   s   || _ || _|| _|| _d S r   r   r   r   r   )r   r   r   r   r   r   r   r   r	   `   s   
zUpdateTableArgs.__init__)r   NNNr   r   r   r   r   r!   S   s    r!   c                 C   s   | j | j| j| jdS )z
    change update_table_args to dict

    :param args: update table args
    :type args: UpdateTableArgs

    :return:
    :rtype dict
    )r   r   r   r   r"   r   r   r   r   update_table_args_2_dictg   s
   r#   c                   @   "   e Zd ZdZdddZdd ZdS )	Cellz`
    Cell
    :param column
    :type column string
    :param value
    :type value string
     c                 C   s   || _ || _d S r   columnvalue)r   r(   r)   r   r   r   r	         
zCell.__init__c                 C      | j | jdS )z
        Convert the Cell instance into a dictionary with keys for column and value.

        :return: A dictionary with 'column' and 'value' as keys, representing
                 the cell's data.
        :rtype: dict
        r'   r'   r   r   r   r   to_dict   s   	zCell.to_dictN)r&   r&   r   r   r   r   r	   r-   r   r   r   r   r%   y   s    
r%   c                   @   2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )Rowz[
    Row
    :param rowkey
    :type rowkey string
    :param cells
    :type cells []
    r&   c                 C   s   || _ g | _d S r   rowkeycells)r   r2   r   r   r   r	      r*   zRow.__init__c                 C      | j | dS z|
        append cell

        :param cell: column & value
        :type cell: Cell

        :return:
        :rtype
        Nr3   appendr   cellr   r   r   append_cell      
zRow.append_cellc                 C      | j S zH
        get cell

        :return cells:
        :rtype Cell[]
        r3   r,   r   r   r   get_cell      zRow.get_cellc                 C   sJ   g }| j D ]}t|tr||  qt|tr|| q| j|dS )a  
        Convert the Row instance into a dictionary suitable for serialization.

        :return: A dictionary with 'rowkey' as the unique identifier and 'cells'
                 containing a list of cell data in dictionary form.
        :rtype: dict
        r1   )r3   
isinstancer%   r7   r-   dictr2   )r   r3   r9   r   r   r   r-      s   



zRow.to_dictNr&   r   r   r   r   r	   r:   r?   r-   r   r   r   r   r0          
	r0   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	BatchPutRowArgsz>
    Batch Put Row Args
    :param rows
    :type rows []
    c                 C   s
   g | _ d S r   rowsr,   r   r   r   r	      r
   zBatchPutRowArgs.__init__c                 C   r4   zi
        append row

        :param row:
        :type row: Row

        :return:
        :rtype
        NrH   r7   r   rowr   r   r   
append_row   r;   zBatchPutRowArgs.append_rowc                 C   r<   zE
        get row

        :return rows:
        :rtype Row[]
        rG   r,   r   r   r   get_row   r@   zBatchPutRowArgs.get_rowN)r   r   r   r   r	   rM   rO   r   r   r   r   rF      s
    rF   c                   @   r$   )		QueryCellz>
    Query Cell
    :param column
    :type column string
    r&   c                 C   r   r   r(   )r   r(   r   r   r   r	      r
   zQueryCell.__init__c                 C   r   )z
        Convert the QueryCell instance into a dictionary

        :return: A dictionary representation of the QueryCell, with 'column' as the key.
        :rtype: dict
        r(   rQ   r,   r   r   r   r-      s   zQueryCell.to_dictNrC   r.   r   r   r   r   rP      s    
rP   c                   @   s2   e Zd ZdZdddZdd Zdd	 Zd
d ZdS )QueryRowArgsz
    Query Row Arg
    :param rowkey
    :type rowkey string
    :param max_versions
    :type max_versions int
    :param cells
    :type cells []
    r&   r   c                 C   s   || _ || _g | _d S r   r2   r   r3   )r   r2   r   r   r   r   r	     s   
zQueryRowArgs.__init__c                 C   r4   r5   r6   r8   r   r   r   r:   
  r;   zQueryRowArgs.append_cellc                 C   r<   r=   r>   r,   r   r   r   r?     r@   zQueryRowArgs.get_cellc                 C   s   dd | j D }| j|dS )z
        Convert the QueryRowArgs instance into a dictionary suitable for serialization.

        :return: A dictionary representation of the QueryRowArgs, including the rowkey and cells.
        :rtype: dict
        c                 S   s"   g | ]}t |d r| n|qS )r-   )hasattrr-   ).0r9   r   r   r   
<listcomp>&  s   " z(QueryRowArgs.to_dict.<locals>.<listcomp>r1   )r3   r2   )r   Z
cells_dictr   r   r   r-     s   zQueryRowArgs.to_dictN)r&   r   rD   r   r   r   r   rR      s    
		rR   c                 C   s   | j | j| jdS )z
    change query_row_args to dict

    :param args: query row args
    :type args: QueryRowArgs

    :return:
    :rtype dict
    )r2   r   r3   rS   r   r   r   r   query_row_args_2_dict-  s   rW   c                   @   r/   )BatchQueryRowArgszs
    Batch Query Row Args
    :param rows
    :type rows []
    :param max_versions
    :type max_versions int
    r   c                 C   s   g | _ || _d S r   rH   r   )r   r   r   r   r   r	   F  r*   zBatchQueryRowArgs.__init__c                 C   r4   rI   rJ   rK   r   r   r   rM   J  r;   zBatchQueryRowArgs.append_rowc                 C   r<   rN   rG   r,   r   r   r   get_rowsV  r@   zBatchQueryRowArgs.get_rowsc                 C   sH   g }| j D ]}t|tr| }nt|tr|}|| q|| jdS )aQ  
        Convert the BatchQueryRowArgs instance to a dictionary for JSON serialization.

        :return: A dictionary representation of the BatchQueryRowArgs instance with
                'rows' key containing a list of rows and 'max_versions' key
                containing the maximum number of versions.
        :rtype: dict
        rY   )rH   rA   rR   r-   rB   r7   r   )r   Z	rows_dataZrow_argZrow_datar   r   r   r-   _  s   	



zBatchQueryRowArgs.to_dictN)r   )r   r   r   r   r	   rM   rZ   r-   r   r   r   r   rX   >  rE   rX   c                 C   r+   )z
    change batch_query_row_args to dict

    :param args: batch query row args
    :type args: BatchQueryRowArgs

    :return:
    :rtype dict
    )r   rH   )r   rH   r   r   r   r   batch_query_row_args_2_dictv  s   r[   c                   @   s6   e Zd ZdZ		dddZdd	 Zd
d Zdd ZdS )ScanArgsai  
    Scan Args
    :param start_rowkey
    :type start_rowkey string
    :param include_start
    :type include_start bool
    :param stop_rowkey
    :type stop_rowkey string
    :param include_stop
    :type include_stop bool
    :param limit
    :type limit int
    :param max_versions
    :type max_versions int
    :param selector
    :type selector []
    r&   TFr   c                 C   s.   || _ || _|| _|| _|| _|| _g | _d S r   )start_rowkeyinclude_startstop_rowkeyinclude_stoplimitr   selector)r   r]   r^   r_   r`   ra   r   r   r   r   r	     s   
zScanArgs.__init__c                 C   r4   )z
        append selector

        :param query_cell:
        :type query_cell: QueryCell

        :return:
        :rtype
        N)rb   r7   )r   Z
query_cellr   r   r   append_selector  r;   zScanArgs.append_selectorc                 C   r<   )zU
        get selector

        :return selector:
        :rtype query_cell[]
        )rb   r,   r   r   r   get_selector  r@   zScanArgs.get_selectorc                 C   s`   g }| j D ]}t|tr|d|ji qt|tr|| q| j| j| j| j	|| j
| jdS )z
        Convert the ScanArgs instance into a dictionary

        :return: A dictionary representation of the scan arguments.
        :rtype: dict
        r(   )startRowkeyincludeStart
stopRowkeyincludeStoprb   r   ra   )rb   rA   rP   r7   r(   rB   r]   r^   r_   r`   r   ra   )r   rb   itemr   r   r   r-     s   



zScanArgs.to_dictN)r&   Tr&   Fr   r   )r   r   r   r   r	   rc   rd   r-   r   r   r   r   r\     s    

	r\   c                 C   s"   | j | j| j| j| j| j| jdS )zy
    change scan_args to dict

    :param args: scan row args
    :type args: ScanArgs

    :return:
    :rtype dict
    )re   rf   rg   rh   rb   ra   r   )r]   r^   r_   r`   rb   ra   r   r   r   r   r   scan_args_2_dict  s   rj   N)r   objectr   r   r   r    r!   r#   r%   r0   rF   rP   rR   rW   rX   r[   r\   rj   r   r   r   r   <module>   s"   
528J