Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "credal"

[tool.poetry]
name = "credal"
version = "0.1.1"
version = "0.1.2"
description = ""
readme = "README.md"
authors = []
Expand Down
74 changes: 74 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,80 @@ client.document_collections.remove_documents_from_collection(
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.document_collections.<a href="src/credal/document_collections/client.py">list_documents_in_collection</a>(...)</code></summary>
<dl>
<dd>

#### 📝 Description

<dl>
<dd>

<dl>
<dd>

List documents in a collection
</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```python
import uuid

from credal import CredalApi

client = CredalApi(
api_key="YOUR_API_KEY",
)
client.document_collections.list_documents_in_collection(
collection_id=uuid.UUID(
"82e4b12a-6990-45d4-8ebd-85c00e030c24",
),
)

```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**collection_id:** `uuid.UUID` — The ID of the document collection to list documents from.

</dd>
</dl>

<dl>
<dd>

**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>
Expand Down
2 changes: 2 additions & 0 deletions src/credal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
from .document_collections import (
CreateCollectionResponse,
DeleteCollectionResponse,
ListDocumentsInCollectionResponse,
MongoCollectionSyncConfig,
MongoCollectionSyncResponse,
MongoSourceFieldsConfig,
Expand Down Expand Up @@ -142,6 +143,7 @@
"InitialChunk",
"InputVariable",
"InsertedAuditLog",
"ListDocumentsInCollectionResponse",
"MessageBlocked",
"MessageFeedback",
"MessageReply",
Expand Down
4 changes: 2 additions & 2 deletions src/credal/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def __init__(

def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"User-Agent": "credal/0.1.1",
"User-Agent": "credal/0.1.2",
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "credal",
"X-Fern-SDK-Version": "0.1.1",
"X-Fern-SDK-Version": "0.1.2",
**(self.get_custom_headers() or {}),
}
headers["Authorization"] = f"Bearer {self._get_api_key()}"
Expand Down
2 changes: 2 additions & 0 deletions src/credal/document_collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .types import (
CreateCollectionResponse,
DeleteCollectionResponse,
ListDocumentsInCollectionResponse,
MongoCollectionSyncConfig,
MongoCollectionSyncResponse,
MongoSourceFieldsConfig,
Expand All @@ -13,6 +14,7 @@
__all__ = [
"CreateCollectionResponse",
"DeleteCollectionResponse",
"ListDocumentsInCollectionResponse",
"MongoCollectionSyncConfig",
"MongoCollectionSyncResponse",
"MongoSourceFieldsConfig",
Expand Down
84 changes: 84 additions & 0 deletions src/credal/document_collections/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .raw_client import AsyncRawDocumentCollectionsClient, RawDocumentCollectionsClient
from .types.create_collection_response import CreateCollectionResponse
from .types.delete_collection_response import DeleteCollectionResponse
from .types.list_documents_in_collection_response import ListDocumentsInCollectionResponse
from .types.mongo_collection_sync_config import MongoCollectionSyncConfig
from .types.mongo_collection_sync_response import MongoCollectionSyncResponse

Expand Down Expand Up @@ -144,6 +145,44 @@ def remove_documents_from_collection(
)
return _response.data

def list_documents_in_collection(
self, *, collection_id: uuid.UUID, request_options: typing.Optional[RequestOptions] = None
) -> ListDocumentsInCollectionResponse:
"""
List documents in a collection

Parameters
----------
collection_id : uuid.UUID
The ID of the document collection to list documents from.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
ListDocumentsInCollectionResponse

Examples
--------
import uuid

from credal import CredalApi

client = CredalApi(
api_key="YOUR_API_KEY",
)
client.document_collections.list_documents_in_collection(
collection_id=uuid.UUID(
"82e4b12a-6990-45d4-8ebd-85c00e030c24",
),
)
"""
_response = self._raw_client.list_documents_in_collection(
collection_id=collection_id, request_options=request_options
)
return _response.data

def create_collection(
self,
*,
Expand Down Expand Up @@ -500,6 +539,51 @@ async def main() -> None:
)
return _response.data

async def list_documents_in_collection(
self, *, collection_id: uuid.UUID, request_options: typing.Optional[RequestOptions] = None
) -> ListDocumentsInCollectionResponse:
"""
List documents in a collection

Parameters
----------
collection_id : uuid.UUID
The ID of the document collection to list documents from.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
ListDocumentsInCollectionResponse

Examples
--------
import asyncio
import uuid

from credal import AsyncCredalApi

client = AsyncCredalApi(
api_key="YOUR_API_KEY",
)


async def main() -> None:
await client.document_collections.list_documents_in_collection(
collection_id=uuid.UUID(
"82e4b12a-6990-45d4-8ebd-85c00e030c24",
),
)


asyncio.run(main())
"""
_response = await self._raw_client.list_documents_in_collection(
collection_id=collection_id, request_options=request_options
)
return _response.data

async def create_collection(
self,
*,
Expand Down
83 changes: 83 additions & 0 deletions src/credal/document_collections/raw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from ..core.serialization import convert_and_respect_annotation_metadata
from .types.create_collection_response import CreateCollectionResponse
from .types.delete_collection_response import DeleteCollectionResponse
from .types.list_documents_in_collection_response import ListDocumentsInCollectionResponse
from .types.mongo_collection_sync_config import MongoCollectionSyncConfig
from .types.mongo_collection_sync_response import MongoCollectionSyncResponse

Expand Down Expand Up @@ -115,6 +116,47 @@ def remove_documents_from_collection(
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

def list_documents_in_collection(
self, *, collection_id: uuid.UUID, request_options: typing.Optional[RequestOptions] = None
) -> HttpResponse[ListDocumentsInCollectionResponse]:
"""
List documents in a collection

Parameters
----------
collection_id : uuid.UUID
The ID of the document collection to list documents from.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
HttpResponse[ListDocumentsInCollectionResponse]
"""
_response = self._client_wrapper.httpx_client.request(
"v0/documentCollections/listDocumentsInCollection",
method="GET",
params={
"collectionId": collection_id,
},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
_data = typing.cast(
ListDocumentsInCollectionResponse,
parse_obj_as(
type_=ListDocumentsInCollectionResponse, # type: ignore
object_=_response.json(),
),
)
return HttpResponse(response=_response, data=_data)
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

def create_collection(
self,
*,
Expand Down Expand Up @@ -416,6 +458,47 @@ async def remove_documents_from_collection(
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

async def list_documents_in_collection(
self, *, collection_id: uuid.UUID, request_options: typing.Optional[RequestOptions] = None
) -> AsyncHttpResponse[ListDocumentsInCollectionResponse]:
"""
List documents in a collection

Parameters
----------
collection_id : uuid.UUID
The ID of the document collection to list documents from.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
AsyncHttpResponse[ListDocumentsInCollectionResponse]
"""
_response = await self._client_wrapper.httpx_client.request(
"v0/documentCollections/listDocumentsInCollection",
method="GET",
params={
"collectionId": collection_id,
},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
_data = typing.cast(
ListDocumentsInCollectionResponse,
parse_obj_as(
type_=ListDocumentsInCollectionResponse, # type: ignore
object_=_response.json(),
),
)
return AsyncHttpResponse(response=_response, data=_data)
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

async def create_collection(
self,
*,
Expand Down
2 changes: 2 additions & 0 deletions src/credal/document_collections/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

from .create_collection_response import CreateCollectionResponse
from .delete_collection_response import DeleteCollectionResponse
from .list_documents_in_collection_response import ListDocumentsInCollectionResponse
from .mongo_collection_sync_config import MongoCollectionSyncConfig
from .mongo_collection_sync_response import MongoCollectionSyncResponse
from .mongo_source_fields_config import MongoSourceFieldsConfig

__all__ = [
"CreateCollectionResponse",
"DeleteCollectionResponse",
"ListDocumentsInCollectionResponse",
"MongoCollectionSyncConfig",
"MongoCollectionSyncResponse",
"MongoSourceFieldsConfig",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ...common.types.resource_identifier import ResourceIdentifier
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ...core.serialization import FieldMetadata


class ListDocumentsInCollectionResponse(UniversalBaseModel):
resource_identifiers: typing_extensions.Annotated[
typing.List[ResourceIdentifier], FieldMetadata(alias="resourceIdentifiers")
]

if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
else:

class Config:
frozen = True
smart_union = True
extra = pydantic.Extra.allow