-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
github-actions
committed
Jun 5, 2024
1 parent
ef4638c
commit feaaac7
Showing
11 changed files
with
256 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,16 @@ print(response.document_chunks) | |
|
||
## Repositories | ||
Repositories act as storage for documents, organized to facilitate efficient information retrieval. Manipulating repository content is straightforward. | ||
### Repository creation | ||
To create a repository, you can use the `create` method provided by the `repositories` API. Here's an example of how to create a repository: | ||
```python | ||
|
||
response = client.repositories.create( | ||
name="Test", | ||
description="Test Repository", | ||
organization="[email protected]" | ||
) | ||
``` | ||
### Document creation | ||
To add a document to a repository, you can use the `create` method provided by the `document` API. Here's an example of how to create and upload a document: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
from http import HTTPStatus | ||
from typing import Dict, Optional | ||
|
||
import httpx | ||
from typing_extensions import Any, Unpack | ||
|
||
from ... import errors | ||
from ...models.repository import Repository | ||
|
||
# from ...client import AuthenticatedClient, Client | ||
from ...types import Response | ||
|
||
|
||
def _get_kwargs( | ||
**body: Unpack[Repository], | ||
) -> Dict[str, Any]: | ||
headers: Dict[str, Any] = {} | ||
|
||
_kwargs: Dict[str, Any] = { | ||
"method": "post", | ||
"url": "/v1/repositories/", | ||
} | ||
|
||
_json_body = body | ||
|
||
_kwargs["json"] = _json_body | ||
headers["Content-Type"] = "application/json" | ||
|
||
_kwargs["headers"] = headers | ||
return _kwargs | ||
|
||
|
||
def _parse_response(*, client, response: httpx.Response) -> Optional[Repository]: | ||
if response.status_code == HTTPStatus.CREATED: | ||
response_201 = Repository.from_dict(response.json()) | ||
|
||
return response_201 | ||
if client.raise_on_unexpected_status: | ||
raise errors.UnexpectedStatus(response.status_code, response.content) | ||
else: | ||
return None | ||
|
||
|
||
def _build_response(*, client, response: httpx.Response) -> Response[Repository]: | ||
return Response( | ||
status_code=HTTPStatus(response.status_code), | ||
content=response.content, | ||
headers=response.headers, | ||
parsed=_parse_response(client=client, response=response), | ||
) | ||
|
||
|
||
def v1_repositories_create_wrapper(client): | ||
def v1_repositories_create_wrapped( | ||
**body: Unpack[Repository], | ||
) -> Repository: | ||
""" | ||
Args: | ||
body (Repository): | ||
body (Repository): | ||
body (Repository): | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Repository] | ||
""" | ||
|
||
kwargs = _get_kwargs( | ||
**body, | ||
) | ||
|
||
httpx_client = client.get_httpx_client() | ||
|
||
response = httpx_client.request( | ||
**kwargs, | ||
) | ||
|
||
return _build_response(client=client, response=response).parsed | ||
|
||
return v1_repositories_create_wrapped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
from typing import Dict, List, Type, Union, cast | ||
|
||
from attrs import define as _attrs_define | ||
from attrs import field as _attrs_field | ||
from typing_extensions import Any, NotRequired, TypedDict, TypeVar | ||
|
||
from ..types import UNSET, Unset | ||
|
||
T = TypeVar("T", bound="Repository") | ||
|
||
|
||
class RepositoryDict(TypedDict): | ||
id: int | ||
name: str | ||
organization: str | ||
description: NotRequired[Union[None, Unset, str]] | ||
pass | ||
|
||
|
||
@_attrs_define | ||
class Repository: | ||
""" | ||
Attributes: | ||
id (int): | ||
name (str): | ||
organization (str): | ||
description (Union[None, Unset, str]): | ||
""" | ||
|
||
id: int | ||
name: str | ||
organization: str | ||
description: Union[None, Unset, str] = UNSET | ||
|
||
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) | ||
|
||
def to_dict(self) -> Dict[str, Any]: | ||
id = self.id | ||
|
||
name = self.name | ||
|
||
organization = self.organization | ||
|
||
description: Union[None, Unset, str] | ||
if isinstance(self.description, Unset): | ||
description = UNSET | ||
else: | ||
description = self.description | ||
|
||
field_dict: Dict[str, Any] = {} | ||
field_dict.update(self.additional_properties) | ||
field_dict.update( | ||
{ | ||
"id": id, | ||
"name": name, | ||
"organization": organization, | ||
} | ||
) | ||
if description is not UNSET: | ||
field_dict["description"] = description | ||
|
||
return field_dict | ||
|
||
def to_multipart(self) -> Dict[str, Any]: | ||
id = self.id if isinstance(self.id, Unset) else (None, str(self.id).encode(), "text/plain") | ||
|
||
name = self.name if isinstance(self.name, Unset) else (None, str(self.name).encode(), "text/plain") | ||
|
||
organization = ( | ||
self.organization | ||
if isinstance(self.organization, Unset) | ||
else (None, str(self.organization).encode(), "text/plain") | ||
) | ||
|
||
description: Union[None, Unset, str] | ||
if isinstance(self.description, Unset): | ||
description = UNSET | ||
else: | ||
description = self.description | ||
|
||
field_dict: Dict[str, Any] = {} | ||
field_dict.update( | ||
{key: (None, str(value).encode(), "text/plain") for key, value in self.additional_properties.items()} | ||
) | ||
field_dict.update( | ||
{ | ||
"id": id, | ||
"name": name, | ||
"organization": organization, | ||
} | ||
) | ||
if description is not UNSET: | ||
field_dict["description"] = description | ||
|
||
return field_dict | ||
|
||
@classmethod | ||
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: | ||
d = src_dict.copy() if src_dict else {} | ||
id = d.pop("id") | ||
|
||
name = d.pop("name") | ||
|
||
organization = d.pop("organization") | ||
|
||
def _parse_description(data: object) -> Union[None, Unset, str]: | ||
if data is None: | ||
return data | ||
if isinstance(data, Unset): | ||
return data | ||
return cast(Union[None, Unset, str], data) | ||
|
||
description = _parse_description(d.pop("description", UNSET)) | ||
|
||
repository = cls( | ||
id=id, | ||
name=name, | ||
organization=organization, | ||
description=description, | ||
) | ||
|
||
repository.additional_properties = d | ||
return repository | ||
|
||
@property | ||
def additional_keys(self) -> List[str]: | ||
return list(self.additional_properties.keys()) | ||
|
||
def __getitem__(self, key: str) -> Any: | ||
return self.additional_properties[key] | ||
|
||
def __setitem__(self, key: str, value: Any) -> None: | ||
self.additional_properties[key] = value | ||
|
||
def __delitem__(self, key: str) -> None: | ||
del self.additional_properties[key] | ||
|
||
def __contains__(self, key: str) -> bool: | ||
return key in self.additional_properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters