
    K:g                         d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
mZ d dlmZmZmZmZ erd dlmZ d dlmZ  G d d      Zy	)
    )cached_property)TYPE_CHECKINGAnyDictListOptionalSequenceUnion)WorkspaceCollaborators)Url
UrlBuildercache_unless_forcedenterprise_only)Api)Basec            
       .   e Zd ZU dZdZee   ed<    G d de      Z	 e
e	      Zdddefd	Zd
edeeeef      ddfdZeedefd              Zeded   fd       Zeedefd              Zedd       Ze	 ddeedf   deed f   dee   ddfd       Zy)	Workspacea  
    Represents an Airtable workspace, which contains a number of bases
    and its own set of collaborators.

    >>> ws = api.workspace("wspmhESAta6clCCwF")
    >>> ws.collaborators().name
    'my first workspace'
    >>> ws.create_base("Base Name", tables=[...])
    <pyairtable.Base base_id="appMhESAta6clCCwF">

    Most workspace functionality is limited to users on Enterprise billing plans.
    N_collaboratorsc                   0    e Zd Z ed      Zedz  Zedz  Zy)Workspace._urlszmeta/workspaces/{id}moveBasecollaboratorsN)__name__
__module____qualname__r   meta	move_baser        U/var/www/html/lionshead/venv/lib/python3.12/site-packages/pyairtable/api/workspace.py_urlsr      s%    )* :%	 .r   r!   apir   workspace_idc                      || _         || _        y N)r"   id)selfr"   r#   s      r    __init__zWorkspace.__init__(   s    r   nametablesreturnr   c                     | j                   j                  j                  }|| j                  t	        |      d}| j                   j                  ||      }| j                   j                  |d   dd      S )a~  
        Create a base in the given workspace.

        See https://airtable.com/developers/web/api/create-base

        Args:
            name: The name to give to the new base. Does not need to be unique.
            tables: A list of ``dict`` objects that conform to Airtable's
                `Table model <https://airtable.com/developers/web/api/model/table-model>`__.
        )r)   workspaceIdr*   jsonr&   T)validateforce)r"   urlsbasesr&   listpostbase)r'   r)   r*   urlpayloadresponses         r    create_basezWorkspace.create_base,   s^     hhmm!!4<P88==7=3xx}}Xd^d$}GGr   c                     dddgi}| j                   j                  | j                  j                  |      }t	        j
                  || j                   |       S )z
        Retrieve basic information, collaborators, and invite links
        for the given workspace, caching the result.

        See https://airtable.com/developers/web/api/get-workspace-collaborators
        includer   inviteLinks)params)context)r"   getr2   r   r   from_api)r'   r>   r8   s      r    r   zWorkspace.collaboratorsB   sJ     o}=>((,,tyy~~f,=%..w$OOr   c                     | j                         j                  D cg c]  }| j                  j                  |       c}S c c}w )z:
        Retrieve all bases within the workspace.
        )r   base_idsr"   r6   )r'   base_ids     r    r3   zWorkspace.basesO   s:    
 7;6H6H6J6S6ST6S7g&6STTTs   "Ac                 6    | j                         j                  S )z,
        The name of the workspace.
        )r   r)   r'   s    r    r)   zWorkspace.nameV   s     !!#(((r   c                 b    | j                   j                  | j                  j                         y)z
        Delete the workspace.

        See https://airtable.com/developers/web/api/delete-workspace

        Usage:
            >>> ws = api.workspace("wspmhESAta6clCCwF")
            >>> ws.delete()
        N)r"   deleter2   r   rF   s    r    rH   zWorkspace.delete^   s     			'r   r6   targetindexc                     t        |t              r|n|j                  }t        |t              r|n|j                  }||d}|||d<   | j                  j	                  | j
                  j                  |       y)a6  
        Move the given base to a new workspace.

        See https://airtable.com/developers/web/api/move-base

        Usage:
            >>> base = api.base("appCwFmhESAta6clC")
            >>> ws = api.workspace("wspmhESAta6clCCwF")
            >>> ws.move_base(base, "wspSomeOtherPlace", index=0)
        )baseIdtargetWorkspaceIdNtargetIndexr.   )
isinstancestrr&   r"   r5   r2   r   )r'   r6   rI   rJ   rD   	target_idr8   s          r    r   zWorkspace.move_basek   sd    " %T3/$TWW(5F699	-49"U%*GM"dii))8r   )r+   Nr%   )r   r   r   __doc__r   r   r   __annotations__r   r!   r   r2   rP   r(   r	   r   r   r:   r   r   r   r   r3   propertyr)   rH   r
   intr   r   r   r    r   r      sL    8<NH34;/
 / 5!DE  HH c3h(H 
	H, 	P5 	P  	P UtF| U U )c )  ) 
( 
( 
  $	9CK 9 c;&'9 }	9
 
9 9r   r   N)	functoolsr   typingr   r   r   r   r   r	   r
   pyairtable.models.schemar   pyairtable.utilsr   r   r   r   pyairtable.api.apir   pyairtable.api.baser   r   r   r   r    <module>r\      s/    % L L L ; R R&(u9 u9r   