
    im                     \    d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZ  G d d      Zy)	    )OptionalList)	ApiClient)
APIKeysApi)require_kwargsparse_non_empty_args)CreateAPIKeyRequestc                       e Zd ZdZdefdZedefd       Zedefd       Z	edefd       Z
edefd	       Zedefd
       Ze	 	 ddededee   deee      fd       Zy)ApiKeyResourcea  
    This class is used to create, delete, list, and fetch API keys.

    .. note::
        The class should not be instantiated directly. Instead, access this classes
        methods through the :class:`pinecone.Admin` class's
        :attr:`api_key` or :attr:`api_keys` attributes.

        .. code-block:: python

            from pinecone import Admin

            admin = Admin()

            project = admin.project.get(name='my-project-name')
            api_keys = admin.api_keys.list(project_id=project.id)
    
api_clientc                 &    t        |      | _        y )N)r   )r   _api_keys_api)selfr   s     r/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/pinecone/admin/resources/api_key.py__init__zApiKeyResource.__init__   s    ':>    
project_idc                 :    | j                   j                  |      S )a  
        List all API keys for a project.

        To find the ``project_id`` for your project, use
        :func:`pinecone.admin.resources.ProjectResource.list`
        or :func:`pinecone.admin.resources.ProjectResource.get`.

        The value of the API key is not returned. The value is only returned
        when a new API key is being created.

        :param project_id: The project_id of the project to list API keys for.
        :type project_id: str
        :return: An object with a list of API keys.
        :rtype: {"data": [APIKey]}

        Examples
        --------

        .. code-block:: python
            :caption: List all API keys for a project
            :emphasize-lines: 9

            from pinecone import Admin

            # Credentials read from PINECONE_CLIENT_ID and
            # PINECONE_CLIENT_SECRET environment variables
            admin = Admin()

            project = admin.project.get(name='my-project-name')

            api_keys = admin.api_key.list(project_id=project.id)
            for api_key in api_keys.data:
                print(api_key.id)
                print(api_key.name)
                print(api_key.description)
                print(api_key.roles)
        )r   )r   list_api_keys)r   r   s     r   listzApiKeyResource.list   s    N !!//:/FFr   
api_key_idc                 :    | j                   j                  |      S )a  
        Fetch an API key by ``api_key_id``.

        The value of the API key is not returned. The value is only returned
        when a new API key is being created.

        :param api_key_id: The id of the API key to fetch.
        :type api_key_id: str
        :return: The API key.
        :rtype: APIKey

        Examples
        --------

        .. code-block:: python
            :caption: Fetch an API key by ``api_key_id``
            :emphasize-lines: 7

            from pinecone import Admin

            # Credentials read from PINECONE_CLIENT_ID and
            # PINECONE_CLIENT_SECRET environment variables
            admin = Admin()

            api_key = admin.api_key.fetch(api_key_id='my-api-key-id')
            print(api_key.id)
            print(api_key.name)
            print(api_key.description)
            print(api_key.roles)
            print(api_key.created_at)

        r   )r   fetch_api_keyr   r   s     r   fetchzApiKeyResource.fetchG   s    D !!//:/FFr   c                 &    | j                  |      S zAlias for :func:`fetch`r   r   r   s     r   getzApiKeyResource.getk        zzZz00r   c                 &    | j                  |      S r   r   r   s     r   describezApiKeyResource.describep   r!   r   c                 :    | j                   j                  |      S )a  
        Delete an API key by ``api_key_id``.

        :param api_key_id: The id of the API key to delete.
        :type api_key_id: str
        :return: ``None``

        Examples
        --------

        .. code-block:: python
            :caption: Delete an API key by api_key_id
            :emphasize-lines: 7

            from pinecone import Admin

            # Credentials read from PINECONE_CLIENT_ID and
            # PINECONE_CLIENT_SECRET environment variables
            admin = Admin()

            admin.api_key.delete(api_key_id='my-api-key-id')

            try:
                admin.api_key.fetch(api_key_id='my-api-key-id')
            except NotFoundException:
                print("API key deleted successfully")

        r   )r   delete_api_keyr   s     r   deletezApiKeyResource.deleteu   s    < !!00J0GGr   Nnamedescriptionrolesc                 z    d|fd|fd|fg}t        di t        |      }| j                  j                  ||      S )a  
        Create an API key for a project.

        The value of the API key is returned in the create response.
        This is the only time the value is returned.

        :param project_id: The project_id of the project to create the API key for.
        :type project_id: str
        :param name: The name of the API key.
        :type name: str
        :param description: The description of the API key.
        :type description: Optional[str]
        :param roles: The roles of the API key. Available roles include:
            ``ProjectEditor``, ``ProjectViewer``, ``ControlPlaneEditor``,
            ``ControlPlaneViewer``, ``DataPlaneEditor``, ``DataPlaneViewer``
        :type roles: Optional[List[str]]
        :return: The created API key object and value.
        :rtype: {"key": APIKey, "value": str}

        Examples
        --------

        .. code-block:: python
            :caption: Create an API key for a project
            :emphasize-lines: 9-14

            from pinecone import Admin

            # Credentials read from PINECONE_CLIENT_ID and
            # PINECONE_CLIENT_SECRET environment variables
            admin = Admin()

            project = admin.project.get(name='my-project-name')

            api_key_response = admin.api_key.create(
                project_id=project.id,
                name='ci-key',
                description='Key for CI testing',
                roles=['ProjectEditor']
            )
            api_key = api_key_response.key
            print(api_key.id)
            print(api_key.name)
            print(api_key.description)
            print(api_key.roles)

            api_key_value = api_key_response.value
            print(api_key_value)
        r'   r(   r)   )r   create_api_key_request )r	   r   r   create_api_key)r   r   r'   r(   r)   argsr+   s          r   createzApiKeyResource.create   sW    r  <w>NO!4!R7KD7Q!R!!00!:P 1 
 	
r   )NN)__name__
__module____qualname____doc__r   r   r   strr   r   r    r#   r&   r   r   r/   r,   r   r   r   r      s    $?9 ? &Gs &G &GP !G !G !GF 1c 1 1 13 1 1 H H H> 
 &*%)<
<
 <
 c]	<

 S	"<
 <
r   r   N)typingr   r   pinecone.openapi_supportr    pinecone.core.openapi.admin.apisr   pinecone.utilsr   r   "pinecone.core.openapi.admin.modelsr	   r   r,   r   r   <module>r:      s     ! . 7 ? BJ
 J
r   