chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
"""A client library for accessing E2B API"""
|
||||
|
||||
from .client import AuthenticatedClient, Client
|
||||
|
||||
__all__ = (
|
||||
"AuthenticatedClient",
|
||||
"Client",
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
"""Contains methods for accessing the API"""
|
||||
@@ -0,0 +1 @@
|
||||
"""Contains endpoint functions for accessing the API"""
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error import Error
|
||||
from ...types import UNSET, Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
volume_id: str,
|
||||
*,
|
||||
path: str,
|
||||
) -> dict[str, Any]:
|
||||
params: dict[str, Any] = {}
|
||||
|
||||
params["path"] = path
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/volumecontent/{volume_id}/path",
|
||||
"params": params,
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, Error]]:
|
||||
if response.status_code == 204:
|
||||
response_204 = cast(Any, None)
|
||||
return response_204
|
||||
if response.status_code == 404:
|
||||
response_404 = Error.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, Error]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Response[Union[Any, Error]]:
|
||||
"""Delete a path
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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[Union[Any, Error]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
path=path,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Optional[Union[Any, Error]]:
|
||||
"""Delete a path
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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:
|
||||
Union[Any, Error]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
path=path,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Response[Union[Any, Error]]:
|
||||
"""Delete a path
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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[Union[Any, Error]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
path=path,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Optional[Union[Any, Error]]:
|
||||
"""Delete a path
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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:
|
||||
Union[Any, Error]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
path=path,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,204 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error import Error
|
||||
from ...models.volume_entry_stat import VolumeEntryStat
|
||||
from ...types import UNSET, Response, Unset
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
volume_id: str,
|
||||
*,
|
||||
path: str,
|
||||
depth: Union[Unset, int] = 1,
|
||||
) -> dict[str, Any]:
|
||||
params: dict[str, Any] = {}
|
||||
|
||||
params["path"] = path
|
||||
|
||||
params["depth"] = depth
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/volumecontent/{volume_id}/dir",
|
||||
"params": params,
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, Error, list["VolumeEntryStat"]]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = []
|
||||
_response_200 = response.json()
|
||||
for componentsschemas_volume_directory_listing_item_data in _response_200:
|
||||
componentsschemas_volume_directory_listing_item = VolumeEntryStat.from_dict(
|
||||
componentsschemas_volume_directory_listing_item_data
|
||||
)
|
||||
|
||||
response_200.append(componentsschemas_volume_directory_listing_item)
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = cast(Any, None)
|
||||
return response_400
|
||||
if response.status_code == 404:
|
||||
response_404 = cast(Any, None)
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = Error.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, Error, list["VolumeEntryStat"]]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
depth: Union[Unset, int] = 1,
|
||||
) -> Response[Union[Any, Error, list["VolumeEntryStat"]]]:
|
||||
"""List directory contents
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
depth (Union[Unset, int]): Default: 1.
|
||||
|
||||
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[Union[Any, Error, list['VolumeEntryStat']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
path=path,
|
||||
depth=depth,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
depth: Union[Unset, int] = 1,
|
||||
) -> Optional[Union[Any, Error, list["VolumeEntryStat"]]]:
|
||||
"""List directory contents
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
depth (Union[Unset, int]): Default: 1.
|
||||
|
||||
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:
|
||||
Union[Any, Error, list['VolumeEntryStat']]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
path=path,
|
||||
depth=depth,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
depth: Union[Unset, int] = 1,
|
||||
) -> Response[Union[Any, Error, list["VolumeEntryStat"]]]:
|
||||
"""List directory contents
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
depth (Union[Unset, int]): Default: 1.
|
||||
|
||||
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[Union[Any, Error, list['VolumeEntryStat']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
path=path,
|
||||
depth=depth,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
depth: Union[Unset, int] = 1,
|
||||
) -> Optional[Union[Any, Error, list["VolumeEntryStat"]]]:
|
||||
"""List directory contents
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
depth (Union[Unset, int]): Default: 1.
|
||||
|
||||
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:
|
||||
Union[Any, Error, list['VolumeEntryStat']]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
path=path,
|
||||
depth=depth,
|
||||
)
|
||||
).parsed
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
from http import HTTPStatus
|
||||
from io import BytesIO
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error import Error
|
||||
from ...types import UNSET, File, Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
volume_id: str,
|
||||
*,
|
||||
path: str,
|
||||
) -> dict[str, Any]:
|
||||
params: dict[str, Any] = {}
|
||||
|
||||
params["path"] = path
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/volumecontent/{volume_id}/file",
|
||||
"params": params,
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, Error, File]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = File(payload=BytesIO(response.content))
|
||||
|
||||
return response_200
|
||||
if response.status_code == 404:
|
||||
response_404 = cast(Any, None)
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = Error.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, Error, File]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Response[Union[Any, Error, File]]:
|
||||
"""Download file
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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[Union[Any, Error, File]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
path=path,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Optional[Union[Any, Error, File]]:
|
||||
"""Download file
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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:
|
||||
Union[Any, Error, File]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
path=path,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Response[Union[Any, Error, File]]:
|
||||
"""Download file
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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[Union[Any, Error, File]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
path=path,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Optional[Union[Any, Error, File]]:
|
||||
"""Download file
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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:
|
||||
Union[Any, Error, File]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
path=path,
|
||||
)
|
||||
).parsed
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error import Error
|
||||
from ...models.volume_entry_stat import VolumeEntryStat
|
||||
from ...types import UNSET, Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
volume_id: str,
|
||||
*,
|
||||
path: str,
|
||||
) -> dict[str, Any]:
|
||||
params: dict[str, Any] = {}
|
||||
|
||||
params["path"] = path
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/volumecontent/{volume_id}/path",
|
||||
"params": params,
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Error, VolumeEntryStat]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = VolumeEntryStat.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 404:
|
||||
response_404 = Error.from_dict(response.json())
|
||||
|
||||
return response_404
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Error, VolumeEntryStat]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Response[Union[Error, VolumeEntryStat]]:
|
||||
"""Get path information
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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[Union[Error, VolumeEntryStat]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
path=path,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Optional[Union[Error, VolumeEntryStat]]:
|
||||
"""Get path information
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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:
|
||||
Union[Error, VolumeEntryStat]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
path=path,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Response[Union[Error, VolumeEntryStat]]:
|
||||
"""Get path information
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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[Union[Error, VolumeEntryStat]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
path=path,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
) -> Optional[Union[Error, VolumeEntryStat]]:
|
||||
"""Get path information
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
|
||||
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:
|
||||
Union[Error, VolumeEntryStat]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
path=path,
|
||||
)
|
||||
).parsed
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.patch_volumecontent_volume_id_path_body import (
|
||||
PatchVolumecontentVolumeIDPathBody,
|
||||
)
|
||||
from ...models.volume_entry_stat import VolumeEntryStat
|
||||
from ...types import UNSET, Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
volume_id: str,
|
||||
*,
|
||||
body: PatchVolumecontentVolumeIDPathBody,
|
||||
path: str,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
params: dict[str, Any] = {}
|
||||
|
||||
params["path"] = path
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "patch",
|
||||
"url": f"/volumecontent/{volume_id}/path",
|
||||
"params": params,
|
||||
}
|
||||
|
||||
_kwargs["json"] = body.to_dict()
|
||||
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, VolumeEntryStat]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = VolumeEntryStat.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_400 = cast(Any, None)
|
||||
return response_400
|
||||
if response.status_code == 404:
|
||||
response_404 = cast(Any, None)
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = cast(Any, None)
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, VolumeEntryStat]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: PatchVolumecontentVolumeIDPathBody,
|
||||
path: str,
|
||||
) -> Response[Union[Any, VolumeEntryStat]]:
|
||||
"""Update path metadata
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
body (PatchVolumecontentVolumeIDPathBody):
|
||||
|
||||
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[Union[Any, VolumeEntryStat]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
body=body,
|
||||
path=path,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: PatchVolumecontentVolumeIDPathBody,
|
||||
path: str,
|
||||
) -> Optional[Union[Any, VolumeEntryStat]]:
|
||||
"""Update path metadata
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
body (PatchVolumecontentVolumeIDPathBody):
|
||||
|
||||
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:
|
||||
Union[Any, VolumeEntryStat]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
body=body,
|
||||
path=path,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: PatchVolumecontentVolumeIDPathBody,
|
||||
path: str,
|
||||
) -> Response[Union[Any, VolumeEntryStat]]:
|
||||
"""Update path metadata
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
body (PatchVolumecontentVolumeIDPathBody):
|
||||
|
||||
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[Union[Any, VolumeEntryStat]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
body=body,
|
||||
path=path,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: PatchVolumecontentVolumeIDPathBody,
|
||||
path: str,
|
||||
) -> Optional[Union[Any, VolumeEntryStat]]:
|
||||
"""Update path metadata
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
body (PatchVolumecontentVolumeIDPathBody):
|
||||
|
||||
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:
|
||||
Union[Any, VolumeEntryStat]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
body=body,
|
||||
path=path,
|
||||
)
|
||||
).parsed
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error import Error
|
||||
from ...models.volume_entry_stat import VolumeEntryStat
|
||||
from ...types import UNSET, Response, Unset
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
volume_id: str,
|
||||
*,
|
||||
path: str,
|
||||
uid: Union[Unset, int] = UNSET,
|
||||
gid: Union[Unset, int] = UNSET,
|
||||
mode: Union[Unset, int] = UNSET,
|
||||
force: Union[Unset, bool] = UNSET,
|
||||
) -> dict[str, Any]:
|
||||
params: dict[str, Any] = {}
|
||||
|
||||
params["path"] = path
|
||||
|
||||
params["uid"] = uid
|
||||
|
||||
params["gid"] = gid
|
||||
|
||||
params["mode"] = mode
|
||||
|
||||
params["force"] = force
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": f"/volumecontent/{volume_id}/dir",
|
||||
"params": params,
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, Error, VolumeEntryStat]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = VolumeEntryStat.from_dict(response.json())
|
||||
|
||||
return response_201
|
||||
if response.status_code == 404:
|
||||
response_404 = cast(Any, None)
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = Error.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, Error, VolumeEntryStat]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
uid: Union[Unset, int] = UNSET,
|
||||
gid: Union[Unset, int] = UNSET,
|
||||
mode: Union[Unset, int] = UNSET,
|
||||
force: Union[Unset, bool] = UNSET,
|
||||
) -> Response[Union[Any, Error, VolumeEntryStat]]:
|
||||
"""Create a directory
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
uid (Union[Unset, int]):
|
||||
gid (Union[Unset, int]):
|
||||
mode (Union[Unset, int]):
|
||||
force (Union[Unset, bool]):
|
||||
|
||||
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[Union[Any, Error, VolumeEntryStat]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
path=path,
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
mode=mode,
|
||||
force=force,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
uid: Union[Unset, int] = UNSET,
|
||||
gid: Union[Unset, int] = UNSET,
|
||||
mode: Union[Unset, int] = UNSET,
|
||||
force: Union[Unset, bool] = UNSET,
|
||||
) -> Optional[Union[Any, Error, VolumeEntryStat]]:
|
||||
"""Create a directory
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
uid (Union[Unset, int]):
|
||||
gid (Union[Unset, int]):
|
||||
mode (Union[Unset, int]):
|
||||
force (Union[Unset, bool]):
|
||||
|
||||
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:
|
||||
Union[Any, Error, VolumeEntryStat]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
path=path,
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
mode=mode,
|
||||
force=force,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
uid: Union[Unset, int] = UNSET,
|
||||
gid: Union[Unset, int] = UNSET,
|
||||
mode: Union[Unset, int] = UNSET,
|
||||
force: Union[Unset, bool] = UNSET,
|
||||
) -> Response[Union[Any, Error, VolumeEntryStat]]:
|
||||
"""Create a directory
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
uid (Union[Unset, int]):
|
||||
gid (Union[Unset, int]):
|
||||
mode (Union[Unset, int]):
|
||||
force (Union[Unset, bool]):
|
||||
|
||||
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[Union[Any, Error, VolumeEntryStat]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
path=path,
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
mode=mode,
|
||||
force=force,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
path: str,
|
||||
uid: Union[Unset, int] = UNSET,
|
||||
gid: Union[Unset, int] = UNSET,
|
||||
mode: Union[Unset, int] = UNSET,
|
||||
force: Union[Unset, bool] = UNSET,
|
||||
) -> Optional[Union[Any, Error, VolumeEntryStat]]:
|
||||
"""Create a directory
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
uid (Union[Unset, int]):
|
||||
gid (Union[Unset, int]):
|
||||
mode (Union[Unset, int]):
|
||||
force (Union[Unset, bool]):
|
||||
|
||||
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:
|
||||
Union[Any, Error, VolumeEntryStat]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
path=path,
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
mode=mode,
|
||||
force=force,
|
||||
)
|
||||
).parsed
|
||||
+259
@@ -0,0 +1,259 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.error import Error
|
||||
from ...models.volume_entry_stat import VolumeEntryStat
|
||||
from ...types import UNSET, File, Response, Unset
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
volume_id: str,
|
||||
*,
|
||||
body: File,
|
||||
path: str,
|
||||
uid: Union[Unset, int] = UNSET,
|
||||
gid: Union[Unset, int] = UNSET,
|
||||
mode: Union[Unset, int] = UNSET,
|
||||
force: Union[Unset, bool] = UNSET,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
params: dict[str, Any] = {}
|
||||
|
||||
params["path"] = path
|
||||
|
||||
params["uid"] = uid
|
||||
|
||||
params["gid"] = gid
|
||||
|
||||
params["mode"] = mode
|
||||
|
||||
params["force"] = force
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "put",
|
||||
"url": f"/volumecontent/{volume_id}/file",
|
||||
"params": params,
|
||||
}
|
||||
|
||||
_kwargs["content"] = body.payload
|
||||
|
||||
headers["Content-Type"] = "application/octet-stream"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, Error, VolumeEntryStat]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = VolumeEntryStat.from_dict(response.json())
|
||||
|
||||
return response_201
|
||||
if response.status_code == 404:
|
||||
response_404 = cast(Any, None)
|
||||
return response_404
|
||||
if response.status_code == 500:
|
||||
response_500 = Error.from_dict(response.json())
|
||||
|
||||
return response_500
|
||||
if client.raise_on_unexpected_status:
|
||||
raise errors.UnexpectedStatus(response.status_code, response.content)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Response[Union[Any, Error, VolumeEntryStat]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: File,
|
||||
path: str,
|
||||
uid: Union[Unset, int] = UNSET,
|
||||
gid: Union[Unset, int] = UNSET,
|
||||
mode: Union[Unset, int] = UNSET,
|
||||
force: Union[Unset, bool] = UNSET,
|
||||
) -> Response[Union[Any, Error, VolumeEntryStat]]:
|
||||
"""Upload file
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
uid (Union[Unset, int]):
|
||||
gid (Union[Unset, int]):
|
||||
mode (Union[Unset, int]):
|
||||
force (Union[Unset, bool]):
|
||||
body (File):
|
||||
|
||||
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[Union[Any, Error, VolumeEntryStat]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
body=body,
|
||||
path=path,
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
mode=mode,
|
||||
force=force,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: File,
|
||||
path: str,
|
||||
uid: Union[Unset, int] = UNSET,
|
||||
gid: Union[Unset, int] = UNSET,
|
||||
mode: Union[Unset, int] = UNSET,
|
||||
force: Union[Unset, bool] = UNSET,
|
||||
) -> Optional[Union[Any, Error, VolumeEntryStat]]:
|
||||
"""Upload file
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
uid (Union[Unset, int]):
|
||||
gid (Union[Unset, int]):
|
||||
mode (Union[Unset, int]):
|
||||
force (Union[Unset, bool]):
|
||||
body (File):
|
||||
|
||||
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:
|
||||
Union[Any, Error, VolumeEntryStat]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
body=body,
|
||||
path=path,
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
mode=mode,
|
||||
force=force,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: File,
|
||||
path: str,
|
||||
uid: Union[Unset, int] = UNSET,
|
||||
gid: Union[Unset, int] = UNSET,
|
||||
mode: Union[Unset, int] = UNSET,
|
||||
force: Union[Unset, bool] = UNSET,
|
||||
) -> Response[Union[Any, Error, VolumeEntryStat]]:
|
||||
"""Upload file
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
uid (Union[Unset, int]):
|
||||
gid (Union[Unset, int]):
|
||||
mode (Union[Unset, int]):
|
||||
force (Union[Unset, bool]):
|
||||
body (File):
|
||||
|
||||
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[Union[Any, Error, VolumeEntryStat]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
volume_id=volume_id,
|
||||
body=body,
|
||||
path=path,
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
mode=mode,
|
||||
force=force,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
volume_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: File,
|
||||
path: str,
|
||||
uid: Union[Unset, int] = UNSET,
|
||||
gid: Union[Unset, int] = UNSET,
|
||||
mode: Union[Unset, int] = UNSET,
|
||||
force: Union[Unset, bool] = UNSET,
|
||||
) -> Optional[Union[Any, Error, VolumeEntryStat]]:
|
||||
"""Upload file
|
||||
|
||||
Args:
|
||||
volume_id (str):
|
||||
path (str):
|
||||
uid (Union[Unset, int]):
|
||||
gid (Union[Unset, int]):
|
||||
mode (Union[Unset, int]):
|
||||
force (Union[Unset, bool]):
|
||||
body (File):
|
||||
|
||||
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:
|
||||
Union[Any, Error, VolumeEntryStat]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
volume_id=volume_id,
|
||||
client=client,
|
||||
body=body,
|
||||
path=path,
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
mode=mode,
|
||||
force=force,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,286 @@
|
||||
import ssl
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
from attrs import define, evolve, field
|
||||
|
||||
|
||||
@define
|
||||
class Client:
|
||||
"""A class for keeping track of data related to the API
|
||||
|
||||
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
||||
|
||||
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
||||
|
||||
``cookies``: A dictionary of cookies to be sent with every request
|
||||
|
||||
``headers``: A dictionary of headers to be sent with every request
|
||||
|
||||
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
||||
httpx.TimeoutException if this is exceeded.
|
||||
|
||||
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
||||
but can be set to False for testing purposes.
|
||||
|
||||
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
||||
|
||||
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
||||
|
||||
|
||||
Attributes:
|
||||
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
||||
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
||||
argument to the constructor.
|
||||
"""
|
||||
|
||||
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
||||
_base_url: str = field(alias="base_url")
|
||||
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
||||
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
||||
_timeout: Optional[httpx.Timeout] = field(
|
||||
default=None, kw_only=True, alias="timeout"
|
||||
)
|
||||
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(
|
||||
default=True, kw_only=True, alias="verify_ssl"
|
||||
)
|
||||
_follow_redirects: bool = field(
|
||||
default=False, kw_only=True, alias="follow_redirects"
|
||||
)
|
||||
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
||||
_client: Optional[httpx.Client] = field(default=None, init=False)
|
||||
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
|
||||
|
||||
def with_headers(self, headers: dict[str, str]) -> "Client":
|
||||
"""Get a new client matching this one with additional headers"""
|
||||
if self._client is not None:
|
||||
self._client.headers.update(headers)
|
||||
if self._async_client is not None:
|
||||
self._async_client.headers.update(headers)
|
||||
return evolve(self, headers={**self._headers, **headers})
|
||||
|
||||
def with_cookies(self, cookies: dict[str, str]) -> "Client":
|
||||
"""Get a new client matching this one with additional cookies"""
|
||||
if self._client is not None:
|
||||
self._client.cookies.update(cookies)
|
||||
if self._async_client is not None:
|
||||
self._async_client.cookies.update(cookies)
|
||||
return evolve(self, cookies={**self._cookies, **cookies})
|
||||
|
||||
def with_timeout(self, timeout: httpx.Timeout) -> "Client":
|
||||
"""Get a new client matching this one with a new timeout (in seconds)"""
|
||||
if self._client is not None:
|
||||
self._client.timeout = timeout
|
||||
if self._async_client is not None:
|
||||
self._async_client.timeout = timeout
|
||||
return evolve(self, timeout=timeout)
|
||||
|
||||
def set_httpx_client(self, client: httpx.Client) -> "Client":
|
||||
"""Manually set the underlying httpx.Client
|
||||
|
||||
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
||||
"""
|
||||
self._client = client
|
||||
return self
|
||||
|
||||
def get_httpx_client(self) -> httpx.Client:
|
||||
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
||||
if self._client is None:
|
||||
self._client = httpx.Client(
|
||||
base_url=self._base_url,
|
||||
cookies=self._cookies,
|
||||
headers=self._headers,
|
||||
timeout=self._timeout,
|
||||
verify=self._verify_ssl,
|
||||
follow_redirects=self._follow_redirects,
|
||||
**self._httpx_args,
|
||||
)
|
||||
return self._client
|
||||
|
||||
def __enter__(self) -> "Client":
|
||||
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
||||
self.get_httpx_client().__enter__()
|
||||
return self
|
||||
|
||||
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
||||
self.get_httpx_client().__exit__(*args, **kwargs)
|
||||
|
||||
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
|
||||
"""Manually the underlying httpx.AsyncClient
|
||||
|
||||
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
||||
"""
|
||||
self._async_client = async_client
|
||||
return self
|
||||
|
||||
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
||||
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
||||
if self._async_client is None:
|
||||
self._async_client = httpx.AsyncClient(
|
||||
base_url=self._base_url,
|
||||
cookies=self._cookies,
|
||||
headers=self._headers,
|
||||
timeout=self._timeout,
|
||||
verify=self._verify_ssl,
|
||||
follow_redirects=self._follow_redirects,
|
||||
**self._httpx_args,
|
||||
)
|
||||
return self._async_client
|
||||
|
||||
async def __aenter__(self) -> "Client":
|
||||
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
||||
await self.get_async_httpx_client().__aenter__()
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
||||
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
||||
|
||||
|
||||
@define
|
||||
class AuthenticatedClient:
|
||||
"""A Client which has been authenticated for use on secured endpoints
|
||||
|
||||
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
||||
|
||||
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
||||
|
||||
``cookies``: A dictionary of cookies to be sent with every request
|
||||
|
||||
``headers``: A dictionary of headers to be sent with every request
|
||||
|
||||
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
||||
httpx.TimeoutException if this is exceeded.
|
||||
|
||||
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
||||
but can be set to False for testing purposes.
|
||||
|
||||
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
||||
|
||||
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
||||
|
||||
|
||||
Attributes:
|
||||
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
||||
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
||||
argument to the constructor.
|
||||
token: The token to use for authentication
|
||||
prefix: The prefix to use for the Authorization header
|
||||
auth_header_name: The name of the Authorization header
|
||||
"""
|
||||
|
||||
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
||||
_base_url: str = field(alias="base_url")
|
||||
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
||||
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
||||
_timeout: Optional[httpx.Timeout] = field(
|
||||
default=None, kw_only=True, alias="timeout"
|
||||
)
|
||||
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(
|
||||
default=True, kw_only=True, alias="verify_ssl"
|
||||
)
|
||||
_follow_redirects: bool = field(
|
||||
default=False, kw_only=True, alias="follow_redirects"
|
||||
)
|
||||
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
||||
_client: Optional[httpx.Client] = field(default=None, init=False)
|
||||
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
|
||||
|
||||
token: str
|
||||
prefix: str = "Bearer"
|
||||
auth_header_name: str = "Authorization"
|
||||
|
||||
def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
|
||||
"""Get a new client matching this one with additional headers"""
|
||||
if self._client is not None:
|
||||
self._client.headers.update(headers)
|
||||
if self._async_client is not None:
|
||||
self._async_client.headers.update(headers)
|
||||
return evolve(self, headers={**self._headers, **headers})
|
||||
|
||||
def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
|
||||
"""Get a new client matching this one with additional cookies"""
|
||||
if self._client is not None:
|
||||
self._client.cookies.update(cookies)
|
||||
if self._async_client is not None:
|
||||
self._async_client.cookies.update(cookies)
|
||||
return evolve(self, cookies={**self._cookies, **cookies})
|
||||
|
||||
def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
|
||||
"""Get a new client matching this one with a new timeout (in seconds)"""
|
||||
if self._client is not None:
|
||||
self._client.timeout = timeout
|
||||
if self._async_client is not None:
|
||||
self._async_client.timeout = timeout
|
||||
return evolve(self, timeout=timeout)
|
||||
|
||||
def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
|
||||
"""Manually set the underlying httpx.Client
|
||||
|
||||
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
||||
"""
|
||||
self._client = client
|
||||
return self
|
||||
|
||||
def get_httpx_client(self) -> httpx.Client:
|
||||
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
||||
if self._client is None:
|
||||
self._headers[self.auth_header_name] = (
|
||||
f"{self.prefix} {self.token}" if self.prefix else self.token
|
||||
)
|
||||
self._client = httpx.Client(
|
||||
base_url=self._base_url,
|
||||
cookies=self._cookies,
|
||||
headers=self._headers,
|
||||
timeout=self._timeout,
|
||||
verify=self._verify_ssl,
|
||||
follow_redirects=self._follow_redirects,
|
||||
**self._httpx_args,
|
||||
)
|
||||
return self._client
|
||||
|
||||
def __enter__(self) -> "AuthenticatedClient":
|
||||
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
||||
self.get_httpx_client().__enter__()
|
||||
return self
|
||||
|
||||
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
||||
self.get_httpx_client().__exit__(*args, **kwargs)
|
||||
|
||||
def set_async_httpx_client(
|
||||
self, async_client: httpx.AsyncClient
|
||||
) -> "AuthenticatedClient":
|
||||
"""Manually the underlying httpx.AsyncClient
|
||||
|
||||
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
||||
"""
|
||||
self._async_client = async_client
|
||||
return self
|
||||
|
||||
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
||||
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
||||
if self._async_client is None:
|
||||
self._headers[self.auth_header_name] = (
|
||||
f"{self.prefix} {self.token}" if self.prefix else self.token
|
||||
)
|
||||
self._async_client = httpx.AsyncClient(
|
||||
base_url=self._base_url,
|
||||
cookies=self._cookies,
|
||||
headers=self._headers,
|
||||
timeout=self._timeout,
|
||||
verify=self._verify_ssl,
|
||||
follow_redirects=self._follow_redirects,
|
||||
**self._httpx_args,
|
||||
)
|
||||
return self._async_client
|
||||
|
||||
async def __aenter__(self) -> "AuthenticatedClient":
|
||||
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
||||
await self.get_async_httpx_client().__aenter__()
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
||||
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
||||
@@ -0,0 +1,16 @@
|
||||
"""Contains shared errors types that can be raised from API functions"""
|
||||
|
||||
|
||||
class UnexpectedStatus(Exception):
|
||||
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
|
||||
|
||||
def __init__(self, status_code: int, content: bytes):
|
||||
self.status_code = status_code
|
||||
self.content = content
|
||||
|
||||
super().__init__(
|
||||
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["UnexpectedStatus"]
|
||||
@@ -0,0 +1,13 @@
|
||||
"""Contains all the data models used in inputs/outputs"""
|
||||
|
||||
from .error import Error
|
||||
from .patch_volumecontent_volume_id_path_body import PatchVolumecontentVolumeIDPathBody
|
||||
from .volume_entry_stat import VolumeEntryStat
|
||||
from .volume_entry_stat_type import VolumeEntryStatType
|
||||
|
||||
__all__ = (
|
||||
"Error",
|
||||
"PatchVolumecontentVolumeIDPathBody",
|
||||
"VolumeEntryStat",
|
||||
"VolumeEntryStatType",
|
||||
)
|
||||
@@ -0,0 +1,67 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="Error")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class Error:
|
||||
"""
|
||||
Attributes:
|
||||
code (str): Error code
|
||||
message (str): Error message
|
||||
"""
|
||||
|
||||
code: str
|
||||
message: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
code = self.code
|
||||
|
||||
message = self.message
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"code": code,
|
||||
"message": message,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
code = d.pop("code")
|
||||
|
||||
message = d.pop("message")
|
||||
|
||||
error = cls(
|
||||
code=code,
|
||||
message=message,
|
||||
)
|
||||
|
||||
error.additional_properties = d
|
||||
return error
|
||||
|
||||
@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
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="PatchVolumecontentVolumeIDPathBody")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class PatchVolumecontentVolumeIDPathBody:
|
||||
"""
|
||||
Attributes:
|
||||
uid (Union[Unset, int]):
|
||||
gid (Union[Unset, int]):
|
||||
mode (Union[Unset, int]):
|
||||
"""
|
||||
|
||||
uid: Union[Unset, int] = UNSET
|
||||
gid: Union[Unset, int] = UNSET
|
||||
mode: Union[Unset, int] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
uid = self.uid
|
||||
|
||||
gid = self.gid
|
||||
|
||||
mode = self.mode
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update({})
|
||||
if uid is not UNSET:
|
||||
field_dict["uid"] = uid
|
||||
if gid is not UNSET:
|
||||
field_dict["gid"] = gid
|
||||
if mode is not UNSET:
|
||||
field_dict["mode"] = mode
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
uid = d.pop("uid", UNSET)
|
||||
|
||||
gid = d.pop("gid", UNSET)
|
||||
|
||||
mode = d.pop("mode", UNSET)
|
||||
|
||||
patch_volumecontent_volume_id_path_body = cls(
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
mode=mode,
|
||||
)
|
||||
|
||||
patch_volumecontent_volume_id_path_body.additional_properties = d
|
||||
return patch_volumecontent_volume_id_path_body
|
||||
|
||||
@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
|
||||
@@ -0,0 +1,145 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
from ..models.volume_entry_stat_type import VolumeEntryStatType
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="VolumeEntryStat")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class VolumeEntryStat:
|
||||
"""
|
||||
Attributes:
|
||||
name (str):
|
||||
type_ (VolumeEntryStatType):
|
||||
path (str):
|
||||
size (int):
|
||||
mode (int):
|
||||
uid (int):
|
||||
gid (int):
|
||||
atime (datetime.datetime):
|
||||
mtime (datetime.datetime):
|
||||
ctime (datetime.datetime):
|
||||
target (Union[Unset, str]):
|
||||
"""
|
||||
|
||||
name: str
|
||||
type_: VolumeEntryStatType
|
||||
path: str
|
||||
size: int
|
||||
mode: int
|
||||
uid: int
|
||||
gid: int
|
||||
atime: datetime.datetime
|
||||
mtime: datetime.datetime
|
||||
ctime: datetime.datetime
|
||||
target: Union[Unset, str] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
name = self.name
|
||||
|
||||
type_ = self.type_.value
|
||||
|
||||
path = self.path
|
||||
|
||||
size = self.size
|
||||
|
||||
mode = self.mode
|
||||
|
||||
uid = self.uid
|
||||
|
||||
gid = self.gid
|
||||
|
||||
atime = self.atime.isoformat()
|
||||
|
||||
mtime = self.mtime.isoformat()
|
||||
|
||||
ctime = self.ctime.isoformat()
|
||||
|
||||
target = self.target
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"name": name,
|
||||
"type": type_,
|
||||
"path": path,
|
||||
"size": size,
|
||||
"mode": mode,
|
||||
"uid": uid,
|
||||
"gid": gid,
|
||||
"atime": atime,
|
||||
"mtime": mtime,
|
||||
"ctime": ctime,
|
||||
}
|
||||
)
|
||||
if target is not UNSET:
|
||||
field_dict["target"] = target
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
name = d.pop("name")
|
||||
|
||||
type_ = VolumeEntryStatType(d.pop("type"))
|
||||
|
||||
path = d.pop("path")
|
||||
|
||||
size = d.pop("size")
|
||||
|
||||
mode = d.pop("mode")
|
||||
|
||||
uid = d.pop("uid")
|
||||
|
||||
gid = d.pop("gid")
|
||||
|
||||
atime = isoparse(d.pop("atime"))
|
||||
|
||||
mtime = isoparse(d.pop("mtime"))
|
||||
|
||||
ctime = isoparse(d.pop("ctime"))
|
||||
|
||||
target = d.pop("target", UNSET)
|
||||
|
||||
volume_entry_stat = cls(
|
||||
name=name,
|
||||
type_=type_,
|
||||
path=path,
|
||||
size=size,
|
||||
mode=mode,
|
||||
uid=uid,
|
||||
gid=gid,
|
||||
atime=atime,
|
||||
mtime=mtime,
|
||||
ctime=ctime,
|
||||
target=target,
|
||||
)
|
||||
|
||||
volume_entry_stat.additional_properties = d
|
||||
return volume_entry_stat
|
||||
|
||||
@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
|
||||
@@ -0,0 +1,11 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class VolumeEntryStatType(str, Enum):
|
||||
DIRECTORY = "directory"
|
||||
FILE = "file"
|
||||
SYMLINK = "symlink"
|
||||
UNKNOWN = "unknown"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.value)
|
||||
@@ -0,0 +1 @@
|
||||
# Marker file for PEP 561
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Contains some shared types for properties"""
|
||||
|
||||
from collections.abc import Mapping, MutableMapping
|
||||
from http import HTTPStatus
|
||||
from typing import IO, BinaryIO, Generic, Literal, Optional, TypeVar, Union
|
||||
|
||||
from attrs import define
|
||||
|
||||
|
||||
class Unset:
|
||||
def __bool__(self) -> Literal[False]:
|
||||
return False
|
||||
|
||||
|
||||
UNSET: Unset = Unset()
|
||||
|
||||
# The types that `httpx.Client(files=)` can accept, copied from that library.
|
||||
FileContent = Union[IO[bytes], bytes, str]
|
||||
FileTypes = Union[
|
||||
# (filename, file (or bytes), content_type)
|
||||
tuple[Optional[str], FileContent, Optional[str]],
|
||||
# (filename, file (or bytes), content_type, headers)
|
||||
tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
|
||||
]
|
||||
RequestFiles = list[tuple[str, FileTypes]]
|
||||
|
||||
|
||||
@define
|
||||
class File:
|
||||
"""Contains information for file uploads"""
|
||||
|
||||
payload: BinaryIO
|
||||
file_name: Optional[str] = None
|
||||
mime_type: Optional[str] = None
|
||||
|
||||
def to_tuple(self) -> FileTypes:
|
||||
"""Return a tuple representation that httpx will accept for multipart/form-data"""
|
||||
return self.file_name, self.payload, self.mime_type
|
||||
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
@define
|
||||
class Response(Generic[T]):
|
||||
"""A response from an endpoint"""
|
||||
|
||||
status_code: HTTPStatus
|
||||
content: bytes
|
||||
headers: MutableMapping[str, str]
|
||||
parsed: Optional[T]
|
||||
|
||||
|
||||
__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]
|
||||
Reference in New Issue
Block a user