mirror of
https://github.com/sstent/FitTrack_GarminSync.git
synced 2026-03-14 08:55:25 +00:00
feat: Initial commit of FitTrack_GarminSync project
This commit is contained in:
0
backend/src/__init__.py
Normal file
0
backend/src/__init__.py
Normal file
BIN
backend/src/__pycache__/__init__.cpython-313.pyc
Normal file
BIN
backend/src/__pycache__/__init__.cpython-313.pyc
Normal file
Binary file not shown.
BIN
backend/src/__pycache__/config.cpython-313.pyc
Normal file
BIN
backend/src/__pycache__/config.cpython-313.pyc
Normal file
Binary file not shown.
BIN
backend/src/__pycache__/dependencies.cpython-313.pyc
Normal file
BIN
backend/src/__pycache__/dependencies.cpython-313.pyc
Normal file
Binary file not shown.
BIN
backend/src/__pycache__/jobs.cpython-313.pyc
Normal file
BIN
backend/src/__pycache__/jobs.cpython-313.pyc
Normal file
Binary file not shown.
BIN
backend/src/__pycache__/logging_config.cpython-313.pyc
Normal file
BIN
backend/src/__pycache__/logging_config.cpython-313.pyc
Normal file
Binary file not shown.
BIN
backend/src/__pycache__/main.cpython-313.pyc
Normal file
BIN
backend/src/__pycache__/main.cpython-313.pyc
Normal file
Binary file not shown.
BIN
backend/src/__pycache__/schemas.cpython-313.pyc
Normal file
BIN
backend/src/__pycache__/schemas.cpython-313.pyc
Normal file
Binary file not shown.
BIN
backend/src/api/__pycache__/garmin_sync.cpython-313.pyc
Normal file
BIN
backend/src/api/__pycache__/garmin_sync.cpython-313.pyc
Normal file
Binary file not shown.
81
backend/src/api/garmin_sync.py
Normal file
81
backend/src/api/garmin_sync.py
Normal file
@@ -0,0 +1,81 @@
|
||||
from typing import Optional, List
|
||||
from uuid import UUID, uuid4
|
||||
from datetime import date, datetime
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, BackgroundTasks
|
||||
|
||||
from ..dependencies import (
|
||||
get_garmin_activity_service,
|
||||
get_garmin_workout_service,
|
||||
get_sync_status_service,
|
||||
get_current_user,
|
||||
)
|
||||
from ..services.garmin_activity_service import GarminActivityService
|
||||
from ..services.garmin_health_service import GarminHealthService
|
||||
from ..services.garmin_workout_service import GarminWorkoutService
|
||||
from ..services.sync_status_service import SyncStatusService
|
||||
from ..jobs import job_store, SyncJob
|
||||
from ..schemas import ActivitySyncRequest, WorkoutUploadRequest, User
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/garmin/activities", response_model=SyncJob, status_code=202)
|
||||
async def trigger_garmin_activity_sync(
|
||||
request: ActivitySyncRequest,
|
||||
background_tasks: BackgroundTasks,
|
||||
garmin_activity_service: GarminActivityService = Depends(get_garmin_activity_service),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""
|
||||
Trigger Garmin Connect Activity Synchronization
|
||||
"""
|
||||
job = job_store.create_job()
|
||||
|
||||
background_tasks.add_task(
|
||||
garmin_activity_service.sync_activities_in_background,
|
||||
job.id,
|
||||
request.force_resync,
|
||||
request.start_date,
|
||||
request.end_date
|
||||
)
|
||||
|
||||
return job
|
||||
|
||||
@router.post("/garmin/workouts", response_model=SyncJob, status_code=202)
|
||||
async def upload_garmin_workout(
|
||||
request: WorkoutUploadRequest,
|
||||
background_tasks: BackgroundTasks,
|
||||
garmin_workout_service: GarminWorkoutService = Depends(get_garmin_workout_service),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""
|
||||
Upload a workout to Garmin Connect
|
||||
"""
|
||||
job = job_store.create_job()
|
||||
|
||||
background_tasks.add_task(
|
||||
garmin_workout_service.upload_workout_in_background,
|
||||
job.id,
|
||||
request.workout_id,
|
||||
)
|
||||
|
||||
return job
|
||||
|
||||
@router.get("/status", response_model=List[SyncJob], status_code=200)
|
||||
async def get_sync_status(
|
||||
job_id: Optional[UUID] = None,
|
||||
limit: int = 10,
|
||||
offset: int = 0,
|
||||
sync_status_service: SyncStatusService = Depends(get_sync_status_service),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""
|
||||
Retrieve the status of synchronization jobs.
|
||||
"""
|
||||
sync_jobs = sync_status_service.get_sync_jobs(
|
||||
job_id=job_id,
|
||||
limit=limit,
|
||||
offset=offset
|
||||
)
|
||||
|
||||
return sync_jobs
|
||||
23
backend/src/central_db_client/.gitignore
vendored
Normal file
23
backend/src/central_db_client/.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
__pycache__/
|
||||
build/
|
||||
dist/
|
||||
*.egg-info/
|
||||
.pytest_cache/
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# JetBrains
|
||||
.idea/
|
||||
|
||||
/coverage.xml
|
||||
/.coverage
|
||||
124
backend/src/central_db_client/README.md
Normal file
124
backend/src/central_db_client/README.md
Normal file
@@ -0,0 +1,124 @@
|
||||
# fit-track-central-db-api-client
|
||||
A client library for accessing FitTrack CentralDB API
|
||||
|
||||
## Usage
|
||||
First, create a client:
|
||||
|
||||
```python
|
||||
from fit_track_central_db_api_client import Client
|
||||
|
||||
client = Client(base_url="https://api.example.com")
|
||||
```
|
||||
|
||||
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
|
||||
|
||||
```python
|
||||
from fit_track_central_db_api_client import AuthenticatedClient
|
||||
|
||||
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
|
||||
```
|
||||
|
||||
Now call your endpoint and use your models:
|
||||
|
||||
```python
|
||||
from fit_track_central_db_api_client.models import MyDataModel
|
||||
from fit_track_central_db_api_client.api.my_tag import get_my_data_model
|
||||
from fit_track_central_db_api_client.types import Response
|
||||
|
||||
with client as client:
|
||||
my_data: MyDataModel = get_my_data_model.sync(client=client)
|
||||
# or if you need more info (e.g. status_code)
|
||||
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
|
||||
```
|
||||
|
||||
Or do the same thing with an async version:
|
||||
|
||||
```python
|
||||
from fit_track_central_db_api_client.models import MyDataModel
|
||||
from fit_track_central_db_api_client.api.my_tag import get_my_data_model
|
||||
from fit_track_central_db_api_client.types import Response
|
||||
|
||||
async with client as client:
|
||||
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
|
||||
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
|
||||
```
|
||||
|
||||
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
|
||||
|
||||
```python
|
||||
client = AuthenticatedClient(
|
||||
base_url="https://internal_api.example.com",
|
||||
token="SuperSecretToken",
|
||||
verify_ssl="/path/to/certificate_bundle.pem",
|
||||
)
|
||||
```
|
||||
|
||||
You can also disable certificate validation altogether, but beware that **this is a security risk**.
|
||||
|
||||
```python
|
||||
client = AuthenticatedClient(
|
||||
base_url="https://internal_api.example.com",
|
||||
token="SuperSecretToken",
|
||||
verify_ssl=False
|
||||
)
|
||||
```
|
||||
|
||||
Things to know:
|
||||
1. Every path/method combo becomes a Python module with four functions:
|
||||
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
|
||||
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
|
||||
1. `asyncio`: Like `sync` but async instead of blocking
|
||||
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
|
||||
|
||||
1. All path/query params, and bodies become method arguments.
|
||||
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
|
||||
1. Any endpoint which did not have a tag will be in `fit_track_central_db_api_client.api.default`
|
||||
|
||||
## Advanced customizations
|
||||
|
||||
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
|
||||
|
||||
```python
|
||||
from fit_track_central_db_api_client import Client
|
||||
|
||||
def log_request(request):
|
||||
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
|
||||
|
||||
def log_response(response):
|
||||
request = response.request
|
||||
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
|
||||
|
||||
client = Client(
|
||||
base_url="https://api.example.com",
|
||||
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
|
||||
)
|
||||
|
||||
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
|
||||
```
|
||||
|
||||
You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
|
||||
|
||||
```python
|
||||
import httpx
|
||||
from fit_track_central_db_api_client import Client
|
||||
|
||||
client = Client(
|
||||
base_url="https://api.example.com",
|
||||
)
|
||||
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
|
||||
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
|
||||
```
|
||||
|
||||
## Building / publishing this package
|
||||
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
|
||||
1. Update the metadata in pyproject.toml (e.g. authors, version)
|
||||
1. If you're using a private repository, configure it with Poetry
|
||||
1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
|
||||
1. `poetry config http-basic.<your-repository-name> <username> <password>`
|
||||
1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
|
||||
|
||||
If you want to install this client into another project without publishing it (e.g. for development) then:
|
||||
1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
|
||||
1. If that project is not using Poetry:
|
||||
1. Build a wheel with `poetry build -f wheel`
|
||||
1. Install that wheel from the other project `pip install <path-to-wheel>`
|
||||
@@ -0,0 +1,8 @@
|
||||
"""A client library for accessing FitTrack CentralDB 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"""
|
||||
@@ -0,0 +1,179 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.analysis_artifact import AnalysisArtifact
|
||||
from ...models.analysis_artifact_create import AnalysisArtifactCreate
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
activity_id: int,
|
||||
*,
|
||||
body: AnalysisArtifactCreate,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": f"/activities/{activity_id}/analysis",
|
||||
}
|
||||
|
||||
_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[AnalysisArtifact, HTTPValidationError]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = AnalysisArtifact.from_dict(response.json())
|
||||
|
||||
return response_201
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[AnalysisArtifact, HTTPValidationError]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: AnalysisArtifactCreate,
|
||||
) -> Response[Union[AnalysisArtifact, HTTPValidationError]]:
|
||||
"""Create Analysis Artifact
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
body (AnalysisArtifactCreate):
|
||||
|
||||
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[AnalysisArtifact, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
activity_id=activity_id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: AnalysisArtifactCreate,
|
||||
) -> Optional[Union[AnalysisArtifact, HTTPValidationError]]:
|
||||
"""Create Analysis Artifact
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
body (AnalysisArtifactCreate):
|
||||
|
||||
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[AnalysisArtifact, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
activity_id=activity_id,
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: AnalysisArtifactCreate,
|
||||
) -> Response[Union[AnalysisArtifact, HTTPValidationError]]:
|
||||
"""Create Analysis Artifact
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
body (AnalysisArtifactCreate):
|
||||
|
||||
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[AnalysisArtifact, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
activity_id=activity_id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: AnalysisArtifactCreate,
|
||||
) -> Optional[Union[AnalysisArtifact, HTTPValidationError]]:
|
||||
"""Create Analysis Artifact
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
body (AnalysisArtifactCreate):
|
||||
|
||||
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[AnalysisArtifact, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
activity_id=activity_id,
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,166 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.coaching_session import CoachingSession
|
||||
from ...models.coaching_session_create import CoachingSessionCreate
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: CoachingSessionCreate,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/coaching/sessions",
|
||||
}
|
||||
|
||||
_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[CoachingSession, HTTPValidationError]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = CoachingSession.from_dict(response.json())
|
||||
|
||||
return response_201
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[CoachingSession, HTTPValidationError]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: CoachingSessionCreate,
|
||||
) -> Response[Union[CoachingSession, HTTPValidationError]]:
|
||||
"""Create Coaching Session
|
||||
|
||||
Args:
|
||||
body (CoachingSessionCreate):
|
||||
|
||||
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[CoachingSession, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: CoachingSessionCreate,
|
||||
) -> Optional[Union[CoachingSession, HTTPValidationError]]:
|
||||
"""Create Coaching Session
|
||||
|
||||
Args:
|
||||
body (CoachingSessionCreate):
|
||||
|
||||
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[CoachingSession, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: CoachingSessionCreate,
|
||||
) -> Response[Union[CoachingSession, HTTPValidationError]]:
|
||||
"""Create Coaching Session
|
||||
|
||||
Args:
|
||||
body (CoachingSessionCreate):
|
||||
|
||||
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[CoachingSession, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: CoachingSessionCreate,
|
||||
) -> Optional[Union[CoachingSession, HTTPValidationError]]:
|
||||
"""Create Coaching Session
|
||||
|
||||
Args:
|
||||
body (CoachingSessionCreate):
|
||||
|
||||
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[CoachingSession, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,166 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.health_metric import HealthMetric
|
||||
from ...models.health_metric_create import HealthMetricCreate
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: HealthMetricCreate,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/health_metrics",
|
||||
}
|
||||
|
||||
_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[HTTPValidationError, HealthMetric]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = HealthMetric.from_dict(response.json())
|
||||
|
||||
return response_201
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, HealthMetric]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: HealthMetricCreate,
|
||||
) -> Response[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Create Health Metric
|
||||
|
||||
Args:
|
||||
body (HealthMetricCreate):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: HealthMetricCreate,
|
||||
) -> Optional[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Create Health Metric
|
||||
|
||||
Args:
|
||||
body (HealthMetricCreate):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: HealthMetricCreate,
|
||||
) -> Response[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Create Health Metric
|
||||
|
||||
Args:
|
||||
body (HealthMetricCreate):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: HealthMetricCreate,
|
||||
) -> Optional[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Create Health Metric
|
||||
|
||||
Args:
|
||||
body (HealthMetricCreate):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,166 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.user import User
|
||||
from ...models.user_create import UserCreate
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: UserCreate,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/users",
|
||||
}
|
||||
|
||||
_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[HTTPValidationError, User]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = User.from_dict(response.json())
|
||||
|
||||
return response_201
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, User]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: UserCreate,
|
||||
) -> Response[Union[HTTPValidationError, User]]:
|
||||
"""Create User
|
||||
|
||||
Args:
|
||||
body (UserCreate):
|
||||
|
||||
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[HTTPValidationError, User]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: UserCreate,
|
||||
) -> Optional[Union[HTTPValidationError, User]]:
|
||||
"""Create User
|
||||
|
||||
Args:
|
||||
body (UserCreate):
|
||||
|
||||
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[HTTPValidationError, User]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: UserCreate,
|
||||
) -> Response[Union[HTTPValidationError, User]]:
|
||||
"""Create User
|
||||
|
||||
Args:
|
||||
body (UserCreate):
|
||||
|
||||
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[HTTPValidationError, User]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: UserCreate,
|
||||
) -> Optional[Union[HTTPValidationError, User]]:
|
||||
"""Create User
|
||||
|
||||
Args:
|
||||
body (UserCreate):
|
||||
|
||||
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[HTTPValidationError, User]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,166 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.workout_plan import WorkoutPlan
|
||||
from ...models.workout_plan_create import WorkoutPlanCreate
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: WorkoutPlanCreate,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/workout_plans",
|
||||
}
|
||||
|
||||
_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[HTTPValidationError, WorkoutPlan]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = WorkoutPlan.from_dict(response.json())
|
||||
|
||||
return response_201
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: WorkoutPlanCreate,
|
||||
) -> Response[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Create Workout Plan
|
||||
|
||||
Args:
|
||||
body (WorkoutPlanCreate):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: WorkoutPlanCreate,
|
||||
) -> Optional[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Create Workout Plan
|
||||
|
||||
Args:
|
||||
body (WorkoutPlanCreate):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: WorkoutPlanCreate,
|
||||
) -> Response[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Create Workout Plan
|
||||
|
||||
Args:
|
||||
body (WorkoutPlanCreate):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: WorkoutPlanCreate,
|
||||
) -> Optional[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Create Workout Plan
|
||||
|
||||
Args:
|
||||
body (WorkoutPlanCreate):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,155 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
metric_id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/health_metrics/{metric_id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
if response.status_code == 204:
|
||||
response_204 = cast(Any, None)
|
||||
return response_204
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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, HTTPValidationError]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
|
||||
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, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
metric_id=metric_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
|
||||
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, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
metric_id=metric_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
|
||||
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, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
metric_id=metric_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
|
||||
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, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
metric_id=metric_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,155 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
user_id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/users/{user_id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
if response.status_code == 204:
|
||||
response_204 = cast(Any, None)
|
||||
return response_204
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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, HTTPValidationError]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Any, HTTPValidationError]]:
|
||||
"""Delete User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
"""Delete User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Any, HTTPValidationError]]:
|
||||
"""Delete User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
"""Delete User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,155 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
plan_id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/workout_plans/{plan_id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
if response.status_code == 204:
|
||||
response_204 = cast(Any, None)
|
||||
return response_204
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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, HTTPValidationError]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
|
||||
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, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
plan_id=plan_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
|
||||
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, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
plan_id=plan_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
|
||||
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, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
plan_id=plan_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
|
||||
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, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
plan_id=plan_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,155 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
activity_id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/activities/{activity_id}/file",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = response.json()
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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, HTTPValidationError]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Any, HTTPValidationError]]:
|
||||
"""Download Activity File
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
|
||||
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, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
activity_id=activity_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
"""Download Activity File
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
|
||||
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, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
activity_id=activity_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Any, HTTPValidationError]]:
|
||||
"""Download Activity File
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
|
||||
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, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
activity_id=activity_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
"""Download Activity File
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
|
||||
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, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
activity_id=activity_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,157 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.activity import Activity
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
activity_id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/activities/{activity_id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Activity, HTTPValidationError]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Activity.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[Activity, HTTPValidationError]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Activity, HTTPValidationError]]:
|
||||
"""Get Activity By Id
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
|
||||
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[Activity, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
activity_id=activity_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Activity, HTTPValidationError]]:
|
||||
"""Get Activity By Id
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
|
||||
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[Activity, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
activity_id=activity_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Activity, HTTPValidationError]]:
|
||||
"""Get Activity By Id
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
|
||||
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[Activity, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
activity_id=activity_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
activity_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Activity, HTTPValidationError]]:
|
||||
"""Get Activity By Id
|
||||
|
||||
Args:
|
||||
activity_id (int):
|
||||
|
||||
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[Activity, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
activity_id=activity_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,132 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.activity import Activity
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/activities",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[list["Activity"]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = []
|
||||
_response_200 = response.json()
|
||||
for response_200_item_data in _response_200:
|
||||
response_200_item = Activity.from_dict(response_200_item_data)
|
||||
|
||||
response_200.append(response_200_item)
|
||||
|
||||
return response_200
|
||||
|
||||
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[list["Activity"]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[list["Activity"]]:
|
||||
"""Get All Activities
|
||||
|
||||
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[list['Activity']]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[list["Activity"]]:
|
||||
"""Get All Activities
|
||||
|
||||
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:
|
||||
list['Activity']
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[list["Activity"]]:
|
||||
"""Get All Activities
|
||||
|
||||
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[list['Activity']]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[list["Activity"]]:
|
||||
"""Get All Activities
|
||||
|
||||
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:
|
||||
list['Activity']
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,132 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.coaching_session import CoachingSession
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/coaching/sessions",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[list["CoachingSession"]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = []
|
||||
_response_200 = response.json()
|
||||
for response_200_item_data in _response_200:
|
||||
response_200_item = CoachingSession.from_dict(response_200_item_data)
|
||||
|
||||
response_200.append(response_200_item)
|
||||
|
||||
return response_200
|
||||
|
||||
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[list["CoachingSession"]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[list["CoachingSession"]]:
|
||||
"""Get All Coaching Sessions
|
||||
|
||||
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[list['CoachingSession']]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[list["CoachingSession"]]:
|
||||
"""Get All Coaching Sessions
|
||||
|
||||
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:
|
||||
list['CoachingSession']
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[list["CoachingSession"]]:
|
||||
"""Get All Coaching Sessions
|
||||
|
||||
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[list['CoachingSession']]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[list["CoachingSession"]]:
|
||||
"""Get All Coaching Sessions
|
||||
|
||||
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:
|
||||
list['CoachingSession']
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,157 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.health_metric import HealthMetric
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
metric_id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/health_metrics/{metric_id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[HTTPValidationError, HealthMetric]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = HealthMetric.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, HealthMetric]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Read Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
metric_id=metric_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Read Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
metric_id=metric_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Read Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
metric_id=metric_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Read Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
metric_id=metric_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,162 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.health_metric import HealthMetric
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
user_id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/users/{user_id}/health_metrics",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[HTTPValidationError, list["HealthMetric"]]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = []
|
||||
_response_200 = response.json()
|
||||
for response_200_item_data in _response_200:
|
||||
response_200_item = HealthMetric.from_dict(response_200_item_data)
|
||||
|
||||
response_200.append(response_200_item)
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, list["HealthMetric"]]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, list["HealthMetric"]]]:
|
||||
"""Read Health Metrics By User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, list['HealthMetric']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, list["HealthMetric"]]]:
|
||||
"""Read Health Metrics By User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, list['HealthMetric']]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, list["HealthMetric"]]]:
|
||||
"""Read Health Metrics By User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, list['HealthMetric']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, list["HealthMetric"]]]:
|
||||
"""Read Health Metrics By User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, list['HealthMetric']]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,157 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.user import User
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
user_id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/users/{user_id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[HTTPValidationError, User]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = User.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, User]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, User]]:
|
||||
"""Read User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, User]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, User]]:
|
||||
"""Read User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, User]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, User]]:
|
||||
"""Read User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, User]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, User]]:
|
||||
"""Read User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, User]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,185 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.user import User
|
||||
from ...types import UNSET, Response, Unset
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
skip: Union[Unset, int] = 0,
|
||||
limit: Union[Unset, int] = 100,
|
||||
) -> dict[str, Any]:
|
||||
params: dict[str, Any] = {}
|
||||
|
||||
params["skip"] = skip
|
||||
|
||||
params["limit"] = limit
|
||||
|
||||
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": "/users",
|
||||
"params": params,
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[HTTPValidationError, list["User"]]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = []
|
||||
_response_200 = response.json()
|
||||
for response_200_item_data in _response_200:
|
||||
response_200_item = User.from_dict(response_200_item_data)
|
||||
|
||||
response_200.append(response_200_item)
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, list["User"]]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
skip: Union[Unset, int] = 0,
|
||||
limit: Union[Unset, int] = 100,
|
||||
) -> Response[Union[HTTPValidationError, list["User"]]]:
|
||||
"""Read Users
|
||||
|
||||
Args:
|
||||
skip (Union[Unset, int]): Default: 0.
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
|
||||
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[HTTPValidationError, list['User']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
skip=skip,
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
skip: Union[Unset, int] = 0,
|
||||
limit: Union[Unset, int] = 100,
|
||||
) -> Optional[Union[HTTPValidationError, list["User"]]]:
|
||||
"""Read Users
|
||||
|
||||
Args:
|
||||
skip (Union[Unset, int]): Default: 0.
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
|
||||
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[HTTPValidationError, list['User']]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
skip=skip,
|
||||
limit=limit,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
skip: Union[Unset, int] = 0,
|
||||
limit: Union[Unset, int] = 100,
|
||||
) -> Response[Union[HTTPValidationError, list["User"]]]:
|
||||
"""Read Users
|
||||
|
||||
Args:
|
||||
skip (Union[Unset, int]): Default: 0.
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
|
||||
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[HTTPValidationError, list['User']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
skip=skip,
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
skip: Union[Unset, int] = 0,
|
||||
limit: Union[Unset, int] = 100,
|
||||
) -> Optional[Union[HTTPValidationError, list["User"]]]:
|
||||
"""Read Users
|
||||
|
||||
Args:
|
||||
skip (Union[Unset, int]): Default: 0.
|
||||
limit (Union[Unset, int]): Default: 100.
|
||||
|
||||
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[HTTPValidationError, list['User']]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
skip=skip,
|
||||
limit=limit,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,157 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.workout_plan import WorkoutPlan
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
plan_id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/workout_plans/{plan_id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = WorkoutPlan.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Read Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
plan_id=plan_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Read Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
plan_id=plan_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Read Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
plan_id=plan_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Read Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
plan_id=plan_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,162 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.workout_plan import WorkoutPlan
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
user_id: int,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/users/{user_id}/workout_plans",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[HTTPValidationError, list["WorkoutPlan"]]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = []
|
||||
_response_200 = response.json()
|
||||
for response_200_item_data in _response_200:
|
||||
response_200_item = WorkoutPlan.from_dict(response_200_item_data)
|
||||
|
||||
response_200.append(response_200_item)
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, list["WorkoutPlan"]]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, list["WorkoutPlan"]]]:
|
||||
"""Read Workout Plans By User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, list['WorkoutPlan']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, list["WorkoutPlan"]]]:
|
||||
"""Read Workout Plans By User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, list['WorkoutPlan']]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, list["WorkoutPlan"]]]:
|
||||
"""Read Workout Plans By User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, list['WorkoutPlan']]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, list["WorkoutPlan"]]]:
|
||||
"""Read Workout Plans By User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
|
||||
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[HTTPValidationError, list['WorkoutPlan']]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,179 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.health_metric import HealthMetric
|
||||
from ...models.health_metric_update import HealthMetricUpdate
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
metric_id: int,
|
||||
*,
|
||||
body: HealthMetricUpdate,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "put",
|
||||
"url": f"/health_metrics/{metric_id}",
|
||||
}
|
||||
|
||||
_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[HTTPValidationError, HealthMetric]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = HealthMetric.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, HealthMetric]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: HealthMetricUpdate,
|
||||
) -> Response[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Update Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
body (HealthMetricUpdate):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
metric_id=metric_id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: HealthMetricUpdate,
|
||||
) -> Optional[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Update Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
body (HealthMetricUpdate):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
metric_id=metric_id,
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: HealthMetricUpdate,
|
||||
) -> Response[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Update Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
body (HealthMetricUpdate):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
metric_id=metric_id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
metric_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: HealthMetricUpdate,
|
||||
) -> Optional[Union[HTTPValidationError, HealthMetric]]:
|
||||
"""Update Health Metric
|
||||
|
||||
Args:
|
||||
metric_id (int):
|
||||
body (HealthMetricUpdate):
|
||||
|
||||
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[HTTPValidationError, HealthMetric]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
metric_id=metric_id,
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,179 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.user import User
|
||||
from ...models.user_update import UserUpdate
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
user_id: int,
|
||||
*,
|
||||
body: UserUpdate,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "put",
|
||||
"url": f"/users/{user_id}",
|
||||
}
|
||||
|
||||
_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[HTTPValidationError, User]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = User.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, User]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: UserUpdate,
|
||||
) -> Response[Union[HTTPValidationError, User]]:
|
||||
"""Update User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
body (UserUpdate):
|
||||
|
||||
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[HTTPValidationError, User]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: UserUpdate,
|
||||
) -> Optional[Union[HTTPValidationError, User]]:
|
||||
"""Update User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
body (UserUpdate):
|
||||
|
||||
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[HTTPValidationError, User]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: UserUpdate,
|
||||
) -> Response[Union[HTTPValidationError, User]]:
|
||||
"""Update User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
body (UserUpdate):
|
||||
|
||||
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[HTTPValidationError, User]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
user_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: UserUpdate,
|
||||
) -> Optional[Union[HTTPValidationError, User]]:
|
||||
"""Update User
|
||||
|
||||
Args:
|
||||
user_id (int):
|
||||
body (UserUpdate):
|
||||
|
||||
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[HTTPValidationError, User]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,179 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.workout_plan import WorkoutPlan
|
||||
from ...models.workout_plan_update import WorkoutPlanUpdate
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
plan_id: int,
|
||||
*,
|
||||
body: WorkoutPlanUpdate,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "put",
|
||||
"url": f"/workout_plans/{plan_id}",
|
||||
}
|
||||
|
||||
_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[HTTPValidationError, WorkoutPlan]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = WorkoutPlan.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: WorkoutPlanUpdate,
|
||||
) -> Response[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Update Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
body (WorkoutPlanUpdate):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
plan_id=plan_id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: WorkoutPlanUpdate,
|
||||
) -> Optional[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Update Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
body (WorkoutPlanUpdate):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
plan_id=plan_id,
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: WorkoutPlanUpdate,
|
||||
) -> Response[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Update Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
body (WorkoutPlanUpdate):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
plan_id=plan_id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
plan_id: int,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: WorkoutPlanUpdate,
|
||||
) -> Optional[Union[HTTPValidationError, WorkoutPlan]]:
|
||||
"""Update Workout Plan
|
||||
|
||||
Args:
|
||||
plan_id (int):
|
||||
body (WorkoutPlanUpdate):
|
||||
|
||||
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[HTTPValidationError, WorkoutPlan]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
plan_id=plan_id,
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,164 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.activity import Activity
|
||||
from ...models.body_upload_activity_activities_post import BodyUploadActivityActivitiesPost
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: BodyUploadActivityActivitiesPost,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/activities",
|
||||
}
|
||||
|
||||
_kwargs["files"] = body.to_multipart()
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Activity, HTTPValidationError]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = Activity.from_dict(response.json())
|
||||
|
||||
return response_201
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[Activity, HTTPValidationError]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: BodyUploadActivityActivitiesPost,
|
||||
) -> Response[Union[Activity, HTTPValidationError]]:
|
||||
"""Upload Activity
|
||||
|
||||
Args:
|
||||
body (BodyUploadActivityActivitiesPost):
|
||||
|
||||
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[Activity, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: BodyUploadActivityActivitiesPost,
|
||||
) -> Optional[Union[Activity, HTTPValidationError]]:
|
||||
"""Upload Activity
|
||||
|
||||
Args:
|
||||
body (BodyUploadActivityActivitiesPost):
|
||||
|
||||
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[Activity, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: BodyUploadActivityActivitiesPost,
|
||||
) -> Response[Union[Activity, HTTPValidationError]]:
|
||||
"""Upload Activity
|
||||
|
||||
Args:
|
||||
body (BodyUploadActivityActivitiesPost):
|
||||
|
||||
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[Activity, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: BodyUploadActivityActivitiesPost,
|
||||
) -> Optional[Union[Activity, HTTPValidationError]]:
|
||||
"""Upload Activity
|
||||
|
||||
Args:
|
||||
body (BodyUploadActivityActivitiesPost):
|
||||
|
||||
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[Activity, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1 @@
|
||||
"""Contains endpoint functions for accessing the API"""
|
||||
@@ -0,0 +1,80 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs() -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": "/",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
|
||||
if response.status_code == 200:
|
||||
return None
|
||||
|
||||
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[Any]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Any]:
|
||||
"""Read Root
|
||||
|
||||
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[Any]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Any]:
|
||||
"""Read Root
|
||||
|
||||
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[Any]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs()
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
@@ -0,0 +1 @@
|
||||
"""Contains endpoint functions for accessing the API"""
|
||||
@@ -0,0 +1,166 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.token import Token
|
||||
from ...models.token_create import TokenCreate
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: TokenCreate,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/tokens/",
|
||||
}
|
||||
|
||||
_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[HTTPValidationError, Token]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = Token.from_dict(response.json())
|
||||
|
||||
return response_201
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, Token]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: TokenCreate,
|
||||
) -> Response[Union[HTTPValidationError, Token]]:
|
||||
"""Create Token Api
|
||||
|
||||
Args:
|
||||
body (TokenCreate):
|
||||
|
||||
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[HTTPValidationError, Token]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: TokenCreate,
|
||||
) -> Optional[Union[HTTPValidationError, Token]]:
|
||||
"""Create Token Api
|
||||
|
||||
Args:
|
||||
body (TokenCreate):
|
||||
|
||||
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[HTTPValidationError, Token]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: TokenCreate,
|
||||
) -> Response[Union[HTTPValidationError, Token]]:
|
||||
"""Create Token Api
|
||||
|
||||
Args:
|
||||
body (TokenCreate):
|
||||
|
||||
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[HTTPValidationError, Token]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: TokenCreate,
|
||||
) -> Optional[Union[HTTPValidationError, Token]]:
|
||||
"""Create Token Api
|
||||
|
||||
Args:
|
||||
body (TokenCreate):
|
||||
|
||||
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[HTTPValidationError, Token]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,155 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
user_id: str,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "delete",
|
||||
"url": f"/tokens/{user_id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
if response.status_code == 204:
|
||||
response_204 = cast(Any, None)
|
||||
return response_204
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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, HTTPValidationError]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Token Api
|
||||
|
||||
Args:
|
||||
user_id (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, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Token Api
|
||||
|
||||
Args:
|
||||
user_id (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, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Token Api
|
||||
|
||||
Args:
|
||||
user_id (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, HTTPValidationError]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[Any, HTTPValidationError]]:
|
||||
"""Delete Token Api
|
||||
|
||||
Args:
|
||||
user_id (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, HTTPValidationError]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,157 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.token import Token
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
user_id: str,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/tokens/{user_id}",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
||||
) -> Optional[Union[HTTPValidationError, Token]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Token.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, Token]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, Token]]:
|
||||
"""Get Token Api
|
||||
|
||||
Args:
|
||||
user_id (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[HTTPValidationError, Token]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, Token]]:
|
||||
"""Get Token Api
|
||||
|
||||
Args:
|
||||
user_id (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[HTTPValidationError, Token]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Response[Union[HTTPValidationError, Token]]:
|
||||
"""Get Token Api
|
||||
|
||||
Args:
|
||||
user_id (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[HTTPValidationError, Token]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
) -> Optional[Union[HTTPValidationError, Token]]:
|
||||
"""Get Token Api
|
||||
|
||||
Args:
|
||||
user_id (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[HTTPValidationError, Token]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,179 @@
|
||||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.http_validation_error import HTTPValidationError
|
||||
from ...models.token import Token
|
||||
from ...models.token_update import TokenUpdate
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
user_id: str,
|
||||
*,
|
||||
body: TokenUpdate,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "put",
|
||||
"url": f"/tokens/{user_id}",
|
||||
}
|
||||
|
||||
_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[HTTPValidationError, Token]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Token.from_dict(response.json())
|
||||
|
||||
return response_200
|
||||
|
||||
if response.status_code == 422:
|
||||
response_422 = HTTPValidationError.from_dict(response.json())
|
||||
|
||||
return response_422
|
||||
|
||||
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[HTTPValidationError, Token]]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: TokenUpdate,
|
||||
) -> Response[Union[HTTPValidationError, Token]]:
|
||||
"""Update Token Api
|
||||
|
||||
Args:
|
||||
user_id (str):
|
||||
body (TokenUpdate):
|
||||
|
||||
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[HTTPValidationError, Token]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: TokenUpdate,
|
||||
) -> Optional[Union[HTTPValidationError, Token]]:
|
||||
"""Update Token Api
|
||||
|
||||
Args:
|
||||
user_id (str):
|
||||
body (TokenUpdate):
|
||||
|
||||
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[HTTPValidationError, Token]
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: TokenUpdate,
|
||||
) -> Response[Union[HTTPValidationError, Token]]:
|
||||
"""Update Token Api
|
||||
|
||||
Args:
|
||||
user_id (str):
|
||||
body (TokenUpdate):
|
||||
|
||||
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[HTTPValidationError, Token]]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
user_id=user_id,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
user_id: str,
|
||||
*,
|
||||
client: Union[AuthenticatedClient, Client],
|
||||
body: TokenUpdate,
|
||||
) -> Optional[Union[HTTPValidationError, Token]]:
|
||||
"""Update Token Api
|
||||
|
||||
Args:
|
||||
user_id (str):
|
||||
body (TokenUpdate):
|
||||
|
||||
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[HTTPValidationError, Token]
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
user_id=user_id,
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
@@ -0,0 +1,268 @@
|
||||
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,67 @@
|
||||
"""Contains all the data models used in inputs/outputs"""
|
||||
|
||||
from .activity import Activity
|
||||
from .activity_activity_metadata_type_0 import ActivityActivityMetadataType0
|
||||
from .analysis_artifact import AnalysisArtifact
|
||||
from .analysis_artifact_create import AnalysisArtifactCreate
|
||||
from .analysis_artifact_create_data import AnalysisArtifactCreateData
|
||||
from .analysis_artifact_data import AnalysisArtifactData
|
||||
from .body_upload_activity_activities_post import BodyUploadActivityActivitiesPost
|
||||
from .coaching_session import CoachingSession
|
||||
from .coaching_session_conversation import CoachingSessionConversation
|
||||
from .coaching_session_create import CoachingSessionCreate
|
||||
from .coaching_session_create_conversation import CoachingSessionCreateConversation
|
||||
from .health_metric import HealthMetric
|
||||
from .health_metric_create import HealthMetricCreate
|
||||
from .health_metric_update import HealthMetricUpdate
|
||||
from .http_validation_error import HTTPValidationError
|
||||
from .token import Token
|
||||
from .token_create import TokenCreate
|
||||
from .token_update import TokenUpdate
|
||||
from .user import User
|
||||
from .user_create import UserCreate
|
||||
from .user_create_preferences_type_0 import UserCreatePreferencesType0
|
||||
from .user_preferences_type_0 import UserPreferencesType0
|
||||
from .user_update import UserUpdate
|
||||
from .user_update_preferences_type_0 import UserUpdatePreferencesType0
|
||||
from .validation_error import ValidationError
|
||||
from .workout_plan import WorkoutPlan
|
||||
from .workout_plan_create import WorkoutPlanCreate
|
||||
from .workout_plan_create_plan_details import WorkoutPlanCreatePlanDetails
|
||||
from .workout_plan_plan_details import WorkoutPlanPlanDetails
|
||||
from .workout_plan_update import WorkoutPlanUpdate
|
||||
from .workout_plan_update_plan_details_type_0 import WorkoutPlanUpdatePlanDetailsType0
|
||||
|
||||
__all__ = (
|
||||
"Activity",
|
||||
"ActivityActivityMetadataType0",
|
||||
"AnalysisArtifact",
|
||||
"AnalysisArtifactCreate",
|
||||
"AnalysisArtifactCreateData",
|
||||
"AnalysisArtifactData",
|
||||
"BodyUploadActivityActivitiesPost",
|
||||
"CoachingSession",
|
||||
"CoachingSessionConversation",
|
||||
"CoachingSessionCreate",
|
||||
"CoachingSessionCreateConversation",
|
||||
"HealthMetric",
|
||||
"HealthMetricCreate",
|
||||
"HealthMetricUpdate",
|
||||
"HTTPValidationError",
|
||||
"Token",
|
||||
"TokenCreate",
|
||||
"TokenUpdate",
|
||||
"User",
|
||||
"UserCreate",
|
||||
"UserCreatePreferencesType0",
|
||||
"UserPreferencesType0",
|
||||
"UserUpdate",
|
||||
"UserUpdatePreferencesType0",
|
||||
"ValidationError",
|
||||
"WorkoutPlan",
|
||||
"WorkoutPlanCreate",
|
||||
"WorkoutPlanCreatePlanDetails",
|
||||
"WorkoutPlanPlanDetails",
|
||||
"WorkoutPlanUpdate",
|
||||
"WorkoutPlanUpdatePlanDetailsType0",
|
||||
)
|
||||
@@ -0,0 +1,125 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.activity_activity_metadata_type_0 import ActivityActivityMetadataType0
|
||||
|
||||
|
||||
T = TypeVar("T", bound="Activity")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class Activity:
|
||||
"""
|
||||
Attributes:
|
||||
user_id (int):
|
||||
file_path (str):
|
||||
id (int):
|
||||
created_at (datetime.datetime):
|
||||
activity_metadata (Union['ActivityActivityMetadataType0', None, Unset]):
|
||||
"""
|
||||
|
||||
user_id: int
|
||||
file_path: str
|
||||
id: int
|
||||
created_at: datetime.datetime
|
||||
activity_metadata: Union["ActivityActivityMetadataType0", None, Unset] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
from ..models.activity_activity_metadata_type_0 import ActivityActivityMetadataType0
|
||||
|
||||
user_id = self.user_id
|
||||
|
||||
file_path = self.file_path
|
||||
|
||||
id = self.id
|
||||
|
||||
created_at = self.created_at.isoformat()
|
||||
|
||||
activity_metadata: Union[None, Unset, dict[str, Any]]
|
||||
if isinstance(self.activity_metadata, Unset):
|
||||
activity_metadata = UNSET
|
||||
elif isinstance(self.activity_metadata, ActivityActivityMetadataType0):
|
||||
activity_metadata = self.activity_metadata.to_dict()
|
||||
else:
|
||||
activity_metadata = self.activity_metadata
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"user_id": user_id,
|
||||
"file_path": file_path,
|
||||
"id": id,
|
||||
"created_at": created_at,
|
||||
}
|
||||
)
|
||||
if activity_metadata is not UNSET:
|
||||
field_dict["activity_metadata"] = activity_metadata
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.activity_activity_metadata_type_0 import ActivityActivityMetadataType0
|
||||
|
||||
d = dict(src_dict)
|
||||
user_id = d.pop("user_id")
|
||||
|
||||
file_path = d.pop("file_path")
|
||||
|
||||
id = d.pop("id")
|
||||
|
||||
created_at = isoparse(d.pop("created_at"))
|
||||
|
||||
def _parse_activity_metadata(data: object) -> Union["ActivityActivityMetadataType0", None, Unset]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
activity_metadata_type_0 = ActivityActivityMetadataType0.from_dict(data)
|
||||
|
||||
return activity_metadata_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union["ActivityActivityMetadataType0", None, Unset], data)
|
||||
|
||||
activity_metadata = _parse_activity_metadata(d.pop("activity_metadata", UNSET))
|
||||
|
||||
activity = cls(
|
||||
user_id=user_id,
|
||||
file_path=file_path,
|
||||
id=id,
|
||||
created_at=created_at,
|
||||
activity_metadata=activity_metadata,
|
||||
)
|
||||
|
||||
activity.additional_properties = d
|
||||
return activity
|
||||
|
||||
@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,44 @@
|
||||
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="ActivityActivityMetadataType0")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class ActivityActivityMetadataType0:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
activity_activity_metadata_type_0 = cls()
|
||||
|
||||
activity_activity_metadata_type_0.additional_properties = d
|
||||
return activity_activity_metadata_type_0
|
||||
|
||||
@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,91 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.analysis_artifact_data import AnalysisArtifactData
|
||||
|
||||
|
||||
T = TypeVar("T", bound="AnalysisArtifact")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class AnalysisArtifact:
|
||||
"""
|
||||
Attributes:
|
||||
activity_id (int):
|
||||
data (AnalysisArtifactData):
|
||||
id (int):
|
||||
created_at (datetime.datetime):
|
||||
"""
|
||||
|
||||
activity_id: int
|
||||
data: "AnalysisArtifactData"
|
||||
id: int
|
||||
created_at: datetime.datetime
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
activity_id = self.activity_id
|
||||
|
||||
data = self.data.to_dict()
|
||||
|
||||
id = self.id
|
||||
|
||||
created_at = self.created_at.isoformat()
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"activity_id": activity_id,
|
||||
"data": data,
|
||||
"id": id,
|
||||
"created_at": created_at,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.analysis_artifact_data import AnalysisArtifactData
|
||||
|
||||
d = dict(src_dict)
|
||||
activity_id = d.pop("activity_id")
|
||||
|
||||
data = AnalysisArtifactData.from_dict(d.pop("data"))
|
||||
|
||||
id = d.pop("id")
|
||||
|
||||
created_at = isoparse(d.pop("created_at"))
|
||||
|
||||
analysis_artifact = cls(
|
||||
activity_id=activity_id,
|
||||
data=data,
|
||||
id=id,
|
||||
created_at=created_at,
|
||||
)
|
||||
|
||||
analysis_artifact.additional_properties = d
|
||||
return analysis_artifact
|
||||
|
||||
@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,65 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.analysis_artifact_create_data import AnalysisArtifactCreateData
|
||||
|
||||
|
||||
T = TypeVar("T", bound="AnalysisArtifactCreate")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class AnalysisArtifactCreate:
|
||||
"""
|
||||
Attributes:
|
||||
data (AnalysisArtifactCreateData):
|
||||
"""
|
||||
|
||||
data: "AnalysisArtifactCreateData"
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
data = self.data.to_dict()
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"data": data,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.analysis_artifact_create_data import AnalysisArtifactCreateData
|
||||
|
||||
d = dict(src_dict)
|
||||
data = AnalysisArtifactCreateData.from_dict(d.pop("data"))
|
||||
|
||||
analysis_artifact_create = cls(
|
||||
data=data,
|
||||
)
|
||||
|
||||
analysis_artifact_create.additional_properties = d
|
||||
return analysis_artifact_create
|
||||
|
||||
@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,44 @@
|
||||
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="AnalysisArtifactCreateData")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class AnalysisArtifactCreateData:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
analysis_artifact_create_data = cls()
|
||||
|
||||
analysis_artifact_create_data.additional_properties = d
|
||||
return analysis_artifact_create_data
|
||||
|
||||
@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,44 @@
|
||||
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="AnalysisArtifactData")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class AnalysisArtifactData:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
analysis_artifact_data = cls()
|
||||
|
||||
analysis_artifact_data.additional_properties = d
|
||||
return analysis_artifact_data
|
||||
|
||||
@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,73 @@
|
||||
from collections.abc import Mapping
|
||||
from io import BytesIO
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from .. import types
|
||||
from ..types import File
|
||||
|
||||
T = TypeVar("T", bound="BodyUploadActivityActivitiesPost")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class BodyUploadActivityActivitiesPost:
|
||||
"""
|
||||
Attributes:
|
||||
file (File):
|
||||
"""
|
||||
|
||||
file: File
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
file = self.file.to_tuple()
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"file": file,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
def to_multipart(self) -> types.RequestFiles:
|
||||
files: types.RequestFiles = []
|
||||
|
||||
files.append(("file", self.file.to_tuple()))
|
||||
|
||||
for prop_name, prop in self.additional_properties.items():
|
||||
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
|
||||
|
||||
return files
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
file = File(payload=BytesIO(d.pop("file")))
|
||||
|
||||
body_upload_activity_activities_post = cls(
|
||||
file=file,
|
||||
)
|
||||
|
||||
body_upload_activity_activities_post.additional_properties = d
|
||||
return body_upload_activity_activities_post
|
||||
|
||||
@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,83 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.coaching_session_conversation import CoachingSessionConversation
|
||||
|
||||
|
||||
T = TypeVar("T", bound="CoachingSession")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class CoachingSession:
|
||||
"""
|
||||
Attributes:
|
||||
conversation (CoachingSessionConversation):
|
||||
id (int):
|
||||
created_at (datetime.datetime):
|
||||
"""
|
||||
|
||||
conversation: "CoachingSessionConversation"
|
||||
id: int
|
||||
created_at: datetime.datetime
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
conversation = self.conversation.to_dict()
|
||||
|
||||
id = self.id
|
||||
|
||||
created_at = self.created_at.isoformat()
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"conversation": conversation,
|
||||
"id": id,
|
||||
"created_at": created_at,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.coaching_session_conversation import CoachingSessionConversation
|
||||
|
||||
d = dict(src_dict)
|
||||
conversation = CoachingSessionConversation.from_dict(d.pop("conversation"))
|
||||
|
||||
id = d.pop("id")
|
||||
|
||||
created_at = isoparse(d.pop("created_at"))
|
||||
|
||||
coaching_session = cls(
|
||||
conversation=conversation,
|
||||
id=id,
|
||||
created_at=created_at,
|
||||
)
|
||||
|
||||
coaching_session.additional_properties = d
|
||||
return coaching_session
|
||||
|
||||
@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,44 @@
|
||||
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="CoachingSessionConversation")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class CoachingSessionConversation:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
coaching_session_conversation = cls()
|
||||
|
||||
coaching_session_conversation.additional_properties = d
|
||||
return coaching_session_conversation
|
||||
|
||||
@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,65 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.coaching_session_create_conversation import CoachingSessionCreateConversation
|
||||
|
||||
|
||||
T = TypeVar("T", bound="CoachingSessionCreate")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class CoachingSessionCreate:
|
||||
"""
|
||||
Attributes:
|
||||
conversation (CoachingSessionCreateConversation):
|
||||
"""
|
||||
|
||||
conversation: "CoachingSessionCreateConversation"
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
conversation = self.conversation.to_dict()
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"conversation": conversation,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.coaching_session_create_conversation import CoachingSessionCreateConversation
|
||||
|
||||
d = dict(src_dict)
|
||||
conversation = CoachingSessionCreateConversation.from_dict(d.pop("conversation"))
|
||||
|
||||
coaching_session_create = cls(
|
||||
conversation=conversation,
|
||||
)
|
||||
|
||||
coaching_session_create.additional_properties = d
|
||||
return coaching_session_create
|
||||
|
||||
@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,44 @@
|
||||
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="CoachingSessionCreateConversation")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class CoachingSessionCreateConversation:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
coaching_session_create_conversation = cls()
|
||||
|
||||
coaching_session_create_conversation.additional_properties = d
|
||||
return coaching_session_create_conversation
|
||||
|
||||
@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,117 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="HealthMetric")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class HealthMetric:
|
||||
"""
|
||||
Attributes:
|
||||
user_id (int):
|
||||
metric_type (str):
|
||||
value (float):
|
||||
id (int):
|
||||
timestamp (Union[None, Unset, datetime.datetime]):
|
||||
"""
|
||||
|
||||
user_id: int
|
||||
metric_type: str
|
||||
value: float
|
||||
id: int
|
||||
timestamp: Union[None, Unset, datetime.datetime] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
user_id = self.user_id
|
||||
|
||||
metric_type = self.metric_type
|
||||
|
||||
value = self.value
|
||||
|
||||
id = self.id
|
||||
|
||||
timestamp: Union[None, Unset, str]
|
||||
if isinstance(self.timestamp, Unset):
|
||||
timestamp = UNSET
|
||||
elif isinstance(self.timestamp, datetime.datetime):
|
||||
timestamp = self.timestamp.isoformat()
|
||||
else:
|
||||
timestamp = self.timestamp
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"user_id": user_id,
|
||||
"metric_type": metric_type,
|
||||
"value": value,
|
||||
"id": id,
|
||||
}
|
||||
)
|
||||
if timestamp is not UNSET:
|
||||
field_dict["timestamp"] = timestamp
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
user_id = d.pop("user_id")
|
||||
|
||||
metric_type = d.pop("metric_type")
|
||||
|
||||
value = d.pop("value")
|
||||
|
||||
id = d.pop("id")
|
||||
|
||||
def _parse_timestamp(data: object) -> Union[None, Unset, datetime.datetime]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
timestamp_type_0 = isoparse(data)
|
||||
|
||||
return timestamp_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[None, Unset, datetime.datetime], data)
|
||||
|
||||
timestamp = _parse_timestamp(d.pop("timestamp", UNSET))
|
||||
|
||||
health_metric = cls(
|
||||
user_id=user_id,
|
||||
metric_type=metric_type,
|
||||
value=value,
|
||||
id=id,
|
||||
timestamp=timestamp,
|
||||
)
|
||||
|
||||
health_metric.additional_properties = d
|
||||
return health_metric
|
||||
|
||||
@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,109 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="HealthMetricCreate")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class HealthMetricCreate:
|
||||
"""
|
||||
Attributes:
|
||||
user_id (int):
|
||||
metric_type (str):
|
||||
value (float):
|
||||
timestamp (Union[None, Unset, datetime.datetime]):
|
||||
"""
|
||||
|
||||
user_id: int
|
||||
metric_type: str
|
||||
value: float
|
||||
timestamp: Union[None, Unset, datetime.datetime] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
user_id = self.user_id
|
||||
|
||||
metric_type = self.metric_type
|
||||
|
||||
value = self.value
|
||||
|
||||
timestamp: Union[None, Unset, str]
|
||||
if isinstance(self.timestamp, Unset):
|
||||
timestamp = UNSET
|
||||
elif isinstance(self.timestamp, datetime.datetime):
|
||||
timestamp = self.timestamp.isoformat()
|
||||
else:
|
||||
timestamp = self.timestamp
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"user_id": user_id,
|
||||
"metric_type": metric_type,
|
||||
"value": value,
|
||||
}
|
||||
)
|
||||
if timestamp is not UNSET:
|
||||
field_dict["timestamp"] = timestamp
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
user_id = d.pop("user_id")
|
||||
|
||||
metric_type = d.pop("metric_type")
|
||||
|
||||
value = d.pop("value")
|
||||
|
||||
def _parse_timestamp(data: object) -> Union[None, Unset, datetime.datetime]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
timestamp_type_0 = isoparse(data)
|
||||
|
||||
return timestamp_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[None, Unset, datetime.datetime], data)
|
||||
|
||||
timestamp = _parse_timestamp(d.pop("timestamp", UNSET))
|
||||
|
||||
health_metric_create = cls(
|
||||
user_id=user_id,
|
||||
metric_type=metric_type,
|
||||
value=value,
|
||||
timestamp=timestamp,
|
||||
)
|
||||
|
||||
health_metric_create.additional_properties = d
|
||||
return health_metric_create
|
||||
|
||||
@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,123 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="HealthMetricUpdate")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class HealthMetricUpdate:
|
||||
"""
|
||||
Attributes:
|
||||
metric_type (Union[None, Unset, str]):
|
||||
value (Union[None, Unset, float]):
|
||||
timestamp (Union[None, Unset, datetime.datetime]):
|
||||
"""
|
||||
|
||||
metric_type: Union[None, Unset, str] = UNSET
|
||||
value: Union[None, Unset, float] = UNSET
|
||||
timestamp: Union[None, Unset, datetime.datetime] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
metric_type: Union[None, Unset, str]
|
||||
if isinstance(self.metric_type, Unset):
|
||||
metric_type = UNSET
|
||||
else:
|
||||
metric_type = self.metric_type
|
||||
|
||||
value: Union[None, Unset, float]
|
||||
if isinstance(self.value, Unset):
|
||||
value = UNSET
|
||||
else:
|
||||
value = self.value
|
||||
|
||||
timestamp: Union[None, Unset, str]
|
||||
if isinstance(self.timestamp, Unset):
|
||||
timestamp = UNSET
|
||||
elif isinstance(self.timestamp, datetime.datetime):
|
||||
timestamp = self.timestamp.isoformat()
|
||||
else:
|
||||
timestamp = self.timestamp
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update({})
|
||||
if metric_type is not UNSET:
|
||||
field_dict["metric_type"] = metric_type
|
||||
if value is not UNSET:
|
||||
field_dict["value"] = value
|
||||
if timestamp is not UNSET:
|
||||
field_dict["timestamp"] = timestamp
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
|
||||
def _parse_metric_type(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)
|
||||
|
||||
metric_type = _parse_metric_type(d.pop("metric_type", UNSET))
|
||||
|
||||
def _parse_value(data: object) -> Union[None, Unset, float]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
return cast(Union[None, Unset, float], data)
|
||||
|
||||
value = _parse_value(d.pop("value", UNSET))
|
||||
|
||||
def _parse_timestamp(data: object) -> Union[None, Unset, datetime.datetime]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
timestamp_type_0 = isoparse(data)
|
||||
|
||||
return timestamp_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[None, Unset, datetime.datetime], data)
|
||||
|
||||
timestamp = _parse_timestamp(d.pop("timestamp", UNSET))
|
||||
|
||||
health_metric_update = cls(
|
||||
metric_type=metric_type,
|
||||
value=value,
|
||||
timestamp=timestamp,
|
||||
)
|
||||
|
||||
health_metric_update.additional_properties = d
|
||||
return health_metric_update
|
||||
|
||||
@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,75 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.validation_error import ValidationError
|
||||
|
||||
|
||||
T = TypeVar("T", bound="HTTPValidationError")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class HTTPValidationError:
|
||||
"""
|
||||
Attributes:
|
||||
detail (Union[Unset, list['ValidationError']]):
|
||||
"""
|
||||
|
||||
detail: Union[Unset, list["ValidationError"]] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
detail: Union[Unset, list[dict[str, Any]]] = UNSET
|
||||
if not isinstance(self.detail, Unset):
|
||||
detail = []
|
||||
for detail_item_data in self.detail:
|
||||
detail_item = detail_item_data.to_dict()
|
||||
detail.append(detail_item)
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update({})
|
||||
if detail is not UNSET:
|
||||
field_dict["detail"] = detail
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.validation_error import ValidationError
|
||||
|
||||
d = dict(src_dict)
|
||||
detail = []
|
||||
_detail = d.pop("detail", UNSET)
|
||||
for detail_item_data in _detail or []:
|
||||
detail_item = ValidationError.from_dict(detail_item_data)
|
||||
|
||||
detail.append(detail_item)
|
||||
|
||||
http_validation_error = cls(
|
||||
detail=detail,
|
||||
)
|
||||
|
||||
http_validation_error.additional_properties = d
|
||||
return http_validation_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
|
||||
@@ -0,0 +1,125 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="Token")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class Token:
|
||||
"""
|
||||
Attributes:
|
||||
access_token (str):
|
||||
refresh_token (str):
|
||||
expires_at (datetime.datetime):
|
||||
user_id (str):
|
||||
created_at (datetime.datetime):
|
||||
updated_at (Union[None, Unset, datetime.datetime]):
|
||||
"""
|
||||
|
||||
access_token: str
|
||||
refresh_token: str
|
||||
expires_at: datetime.datetime
|
||||
user_id: str
|
||||
created_at: datetime.datetime
|
||||
updated_at: Union[None, Unset, datetime.datetime] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
access_token = self.access_token
|
||||
|
||||
refresh_token = self.refresh_token
|
||||
|
||||
expires_at = self.expires_at.isoformat()
|
||||
|
||||
user_id = self.user_id
|
||||
|
||||
created_at = self.created_at.isoformat()
|
||||
|
||||
updated_at: Union[None, Unset, str]
|
||||
if isinstance(self.updated_at, Unset):
|
||||
updated_at = UNSET
|
||||
elif isinstance(self.updated_at, datetime.datetime):
|
||||
updated_at = self.updated_at.isoformat()
|
||||
else:
|
||||
updated_at = self.updated_at
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"access_token": access_token,
|
||||
"refresh_token": refresh_token,
|
||||
"expires_at": expires_at,
|
||||
"user_id": user_id,
|
||||
"created_at": created_at,
|
||||
}
|
||||
)
|
||||
if updated_at is not UNSET:
|
||||
field_dict["updated_at"] = updated_at
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
access_token = d.pop("access_token")
|
||||
|
||||
refresh_token = d.pop("refresh_token")
|
||||
|
||||
expires_at = isoparse(d.pop("expires_at"))
|
||||
|
||||
user_id = d.pop("user_id")
|
||||
|
||||
created_at = isoparse(d.pop("created_at"))
|
||||
|
||||
def _parse_updated_at(data: object) -> Union[None, Unset, datetime.datetime]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
updated_at_type_0 = isoparse(data)
|
||||
|
||||
return updated_at_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[None, Unset, datetime.datetime], data)
|
||||
|
||||
updated_at = _parse_updated_at(d.pop("updated_at", UNSET))
|
||||
|
||||
token = cls(
|
||||
access_token=access_token,
|
||||
refresh_token=refresh_token,
|
||||
expires_at=expires_at,
|
||||
user_id=user_id,
|
||||
created_at=created_at,
|
||||
updated_at=updated_at,
|
||||
)
|
||||
|
||||
token.additional_properties = d
|
||||
return token
|
||||
|
||||
@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,85 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
T = TypeVar("T", bound="TokenCreate")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class TokenCreate:
|
||||
"""
|
||||
Attributes:
|
||||
access_token (str):
|
||||
refresh_token (str):
|
||||
expires_at (datetime.datetime):
|
||||
user_id (str):
|
||||
"""
|
||||
|
||||
access_token: str
|
||||
refresh_token: str
|
||||
expires_at: datetime.datetime
|
||||
user_id: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
access_token = self.access_token
|
||||
|
||||
refresh_token = self.refresh_token
|
||||
|
||||
expires_at = self.expires_at.isoformat()
|
||||
|
||||
user_id = self.user_id
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"access_token": access_token,
|
||||
"refresh_token": refresh_token,
|
||||
"expires_at": expires_at,
|
||||
"user_id": user_id,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
access_token = d.pop("access_token")
|
||||
|
||||
refresh_token = d.pop("refresh_token")
|
||||
|
||||
expires_at = isoparse(d.pop("expires_at"))
|
||||
|
||||
user_id = d.pop("user_id")
|
||||
|
||||
token_create = cls(
|
||||
access_token=access_token,
|
||||
refresh_token=refresh_token,
|
||||
expires_at=expires_at,
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
token_create.additional_properties = d
|
||||
return token_create
|
||||
|
||||
@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,77 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
T = TypeVar("T", bound="TokenUpdate")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class TokenUpdate:
|
||||
"""
|
||||
Attributes:
|
||||
access_token (str):
|
||||
refresh_token (str):
|
||||
expires_at (datetime.datetime):
|
||||
"""
|
||||
|
||||
access_token: str
|
||||
refresh_token: str
|
||||
expires_at: datetime.datetime
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
access_token = self.access_token
|
||||
|
||||
refresh_token = self.refresh_token
|
||||
|
||||
expires_at = self.expires_at.isoformat()
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"access_token": access_token,
|
||||
"refresh_token": refresh_token,
|
||||
"expires_at": expires_at,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
access_token = d.pop("access_token")
|
||||
|
||||
refresh_token = d.pop("refresh_token")
|
||||
|
||||
expires_at = isoparse(d.pop("expires_at"))
|
||||
|
||||
token_update = cls(
|
||||
access_token=access_token,
|
||||
refresh_token=refresh_token,
|
||||
expires_at=expires_at,
|
||||
)
|
||||
|
||||
token_update.additional_properties = d
|
||||
return token_update
|
||||
|
||||
@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,115 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.user_preferences_type_0 import UserPreferencesType0
|
||||
|
||||
|
||||
T = TypeVar("T", bound="User")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class User:
|
||||
"""
|
||||
Attributes:
|
||||
name (str):
|
||||
email (str):
|
||||
id (int):
|
||||
preferences (Union['UserPreferencesType0', None, Unset]):
|
||||
"""
|
||||
|
||||
name: str
|
||||
email: str
|
||||
id: int
|
||||
preferences: Union["UserPreferencesType0", None, Unset] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
from ..models.user_preferences_type_0 import UserPreferencesType0
|
||||
|
||||
name = self.name
|
||||
|
||||
email = self.email
|
||||
|
||||
id = self.id
|
||||
|
||||
preferences: Union[None, Unset, dict[str, Any]]
|
||||
if isinstance(self.preferences, Unset):
|
||||
preferences = UNSET
|
||||
elif isinstance(self.preferences, UserPreferencesType0):
|
||||
preferences = self.preferences.to_dict()
|
||||
else:
|
||||
preferences = self.preferences
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"name": name,
|
||||
"email": email,
|
||||
"id": id,
|
||||
}
|
||||
)
|
||||
if preferences is not UNSET:
|
||||
field_dict["preferences"] = preferences
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.user_preferences_type_0 import UserPreferencesType0
|
||||
|
||||
d = dict(src_dict)
|
||||
name = d.pop("name")
|
||||
|
||||
email = d.pop("email")
|
||||
|
||||
id = d.pop("id")
|
||||
|
||||
def _parse_preferences(data: object) -> Union["UserPreferencesType0", None, Unset]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
preferences_type_0 = UserPreferencesType0.from_dict(data)
|
||||
|
||||
return preferences_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union["UserPreferencesType0", None, Unset], data)
|
||||
|
||||
preferences = _parse_preferences(d.pop("preferences", UNSET))
|
||||
|
||||
user = cls(
|
||||
name=name,
|
||||
email=email,
|
||||
id=id,
|
||||
preferences=preferences,
|
||||
)
|
||||
|
||||
user.additional_properties = d
|
||||
return user
|
||||
|
||||
@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,107 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.user_create_preferences_type_0 import UserCreatePreferencesType0
|
||||
|
||||
|
||||
T = TypeVar("T", bound="UserCreate")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UserCreate:
|
||||
"""
|
||||
Attributes:
|
||||
name (str):
|
||||
email (str):
|
||||
preferences (Union['UserCreatePreferencesType0', None, Unset]):
|
||||
"""
|
||||
|
||||
name: str
|
||||
email: str
|
||||
preferences: Union["UserCreatePreferencesType0", None, Unset] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
from ..models.user_create_preferences_type_0 import UserCreatePreferencesType0
|
||||
|
||||
name = self.name
|
||||
|
||||
email = self.email
|
||||
|
||||
preferences: Union[None, Unset, dict[str, Any]]
|
||||
if isinstance(self.preferences, Unset):
|
||||
preferences = UNSET
|
||||
elif isinstance(self.preferences, UserCreatePreferencesType0):
|
||||
preferences = self.preferences.to_dict()
|
||||
else:
|
||||
preferences = self.preferences
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"name": name,
|
||||
"email": email,
|
||||
}
|
||||
)
|
||||
if preferences is not UNSET:
|
||||
field_dict["preferences"] = preferences
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.user_create_preferences_type_0 import UserCreatePreferencesType0
|
||||
|
||||
d = dict(src_dict)
|
||||
name = d.pop("name")
|
||||
|
||||
email = d.pop("email")
|
||||
|
||||
def _parse_preferences(data: object) -> Union["UserCreatePreferencesType0", None, Unset]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
preferences_type_0 = UserCreatePreferencesType0.from_dict(data)
|
||||
|
||||
return preferences_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union["UserCreatePreferencesType0", None, Unset], data)
|
||||
|
||||
preferences = _parse_preferences(d.pop("preferences", UNSET))
|
||||
|
||||
user_create = cls(
|
||||
name=name,
|
||||
email=email,
|
||||
preferences=preferences,
|
||||
)
|
||||
|
||||
user_create.additional_properties = d
|
||||
return user_create
|
||||
|
||||
@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,44 @@
|
||||
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="UserCreatePreferencesType0")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UserCreatePreferencesType0:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
user_create_preferences_type_0 = cls()
|
||||
|
||||
user_create_preferences_type_0.additional_properties = d
|
||||
return user_create_preferences_type_0
|
||||
|
||||
@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,44 @@
|
||||
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="UserPreferencesType0")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UserPreferencesType0:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
user_preferences_type_0 = cls()
|
||||
|
||||
user_preferences_type_0.additional_properties = d
|
||||
return user_preferences_type_0
|
||||
|
||||
@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,129 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.user_update_preferences_type_0 import UserUpdatePreferencesType0
|
||||
|
||||
|
||||
T = TypeVar("T", bound="UserUpdate")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UserUpdate:
|
||||
"""
|
||||
Attributes:
|
||||
name (Union[None, Unset, str]):
|
||||
email (Union[None, Unset, str]):
|
||||
preferences (Union['UserUpdatePreferencesType0', None, Unset]):
|
||||
"""
|
||||
|
||||
name: Union[None, Unset, str] = UNSET
|
||||
email: Union[None, Unset, str] = UNSET
|
||||
preferences: Union["UserUpdatePreferencesType0", None, Unset] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
from ..models.user_update_preferences_type_0 import UserUpdatePreferencesType0
|
||||
|
||||
name: Union[None, Unset, str]
|
||||
if isinstance(self.name, Unset):
|
||||
name = UNSET
|
||||
else:
|
||||
name = self.name
|
||||
|
||||
email: Union[None, Unset, str]
|
||||
if isinstance(self.email, Unset):
|
||||
email = UNSET
|
||||
else:
|
||||
email = self.email
|
||||
|
||||
preferences: Union[None, Unset, dict[str, Any]]
|
||||
if isinstance(self.preferences, Unset):
|
||||
preferences = UNSET
|
||||
elif isinstance(self.preferences, UserUpdatePreferencesType0):
|
||||
preferences = self.preferences.to_dict()
|
||||
else:
|
||||
preferences = self.preferences
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update({})
|
||||
if name is not UNSET:
|
||||
field_dict["name"] = name
|
||||
if email is not UNSET:
|
||||
field_dict["email"] = email
|
||||
if preferences is not UNSET:
|
||||
field_dict["preferences"] = preferences
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.user_update_preferences_type_0 import UserUpdatePreferencesType0
|
||||
|
||||
d = dict(src_dict)
|
||||
|
||||
def _parse_name(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)
|
||||
|
||||
name = _parse_name(d.pop("name", UNSET))
|
||||
|
||||
def _parse_email(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)
|
||||
|
||||
email = _parse_email(d.pop("email", UNSET))
|
||||
|
||||
def _parse_preferences(data: object) -> Union["UserUpdatePreferencesType0", None, Unset]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
preferences_type_0 = UserUpdatePreferencesType0.from_dict(data)
|
||||
|
||||
return preferences_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union["UserUpdatePreferencesType0", None, Unset], data)
|
||||
|
||||
preferences = _parse_preferences(d.pop("preferences", UNSET))
|
||||
|
||||
user_update = cls(
|
||||
name=name,
|
||||
email=email,
|
||||
preferences=preferences,
|
||||
)
|
||||
|
||||
user_update.additional_properties = d
|
||||
return user_update
|
||||
|
||||
@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,44 @@
|
||||
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="UserUpdatePreferencesType0")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UserUpdatePreferencesType0:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
user_update_preferences_type_0 = cls()
|
||||
|
||||
user_update_preferences_type_0.additional_properties = d
|
||||
return user_update_preferences_type_0
|
||||
|
||||
@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,88 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="ValidationError")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class ValidationError:
|
||||
"""
|
||||
Attributes:
|
||||
loc (list[Union[int, str]]):
|
||||
msg (str):
|
||||
type_ (str):
|
||||
"""
|
||||
|
||||
loc: list[Union[int, str]]
|
||||
msg: str
|
||||
type_: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
loc = []
|
||||
for loc_item_data in self.loc:
|
||||
loc_item: Union[int, str]
|
||||
loc_item = loc_item_data
|
||||
loc.append(loc_item)
|
||||
|
||||
msg = self.msg
|
||||
|
||||
type_ = self.type_
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"loc": loc,
|
||||
"msg": msg,
|
||||
"type": type_,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
loc = []
|
||||
_loc = d.pop("loc")
|
||||
for loc_item_data in _loc:
|
||||
|
||||
def _parse_loc_item(data: object) -> Union[int, str]:
|
||||
return cast(Union[int, str], data)
|
||||
|
||||
loc_item = _parse_loc_item(loc_item_data)
|
||||
|
||||
loc.append(loc_item)
|
||||
|
||||
msg = d.pop("msg")
|
||||
|
||||
type_ = d.pop("type")
|
||||
|
||||
validation_error = cls(
|
||||
loc=loc,
|
||||
msg=msg,
|
||||
type_=type_,
|
||||
)
|
||||
|
||||
validation_error.additional_properties = d
|
||||
return validation_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
|
||||
@@ -0,0 +1,91 @@
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.workout_plan_plan_details import WorkoutPlanPlanDetails
|
||||
|
||||
|
||||
T = TypeVar("T", bound="WorkoutPlan")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class WorkoutPlan:
|
||||
"""
|
||||
Attributes:
|
||||
user_id (int):
|
||||
plan_details (WorkoutPlanPlanDetails):
|
||||
id (int):
|
||||
created_at (datetime.datetime):
|
||||
"""
|
||||
|
||||
user_id: int
|
||||
plan_details: "WorkoutPlanPlanDetails"
|
||||
id: int
|
||||
created_at: datetime.datetime
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
user_id = self.user_id
|
||||
|
||||
plan_details = self.plan_details.to_dict()
|
||||
|
||||
id = self.id
|
||||
|
||||
created_at = self.created_at.isoformat()
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"user_id": user_id,
|
||||
"plan_details": plan_details,
|
||||
"id": id,
|
||||
"created_at": created_at,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.workout_plan_plan_details import WorkoutPlanPlanDetails
|
||||
|
||||
d = dict(src_dict)
|
||||
user_id = d.pop("user_id")
|
||||
|
||||
plan_details = WorkoutPlanPlanDetails.from_dict(d.pop("plan_details"))
|
||||
|
||||
id = d.pop("id")
|
||||
|
||||
created_at = isoparse(d.pop("created_at"))
|
||||
|
||||
workout_plan = cls(
|
||||
user_id=user_id,
|
||||
plan_details=plan_details,
|
||||
id=id,
|
||||
created_at=created_at,
|
||||
)
|
||||
|
||||
workout_plan.additional_properties = d
|
||||
return workout_plan
|
||||
|
||||
@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,73 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.workout_plan_create_plan_details import WorkoutPlanCreatePlanDetails
|
||||
|
||||
|
||||
T = TypeVar("T", bound="WorkoutPlanCreate")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class WorkoutPlanCreate:
|
||||
"""
|
||||
Attributes:
|
||||
user_id (int):
|
||||
plan_details (WorkoutPlanCreatePlanDetails):
|
||||
"""
|
||||
|
||||
user_id: int
|
||||
plan_details: "WorkoutPlanCreatePlanDetails"
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
user_id = self.user_id
|
||||
|
||||
plan_details = self.plan_details.to_dict()
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"user_id": user_id,
|
||||
"plan_details": plan_details,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.workout_plan_create_plan_details import WorkoutPlanCreatePlanDetails
|
||||
|
||||
d = dict(src_dict)
|
||||
user_id = d.pop("user_id")
|
||||
|
||||
plan_details = WorkoutPlanCreatePlanDetails.from_dict(d.pop("plan_details"))
|
||||
|
||||
workout_plan_create = cls(
|
||||
user_id=user_id,
|
||||
plan_details=plan_details,
|
||||
)
|
||||
|
||||
workout_plan_create.additional_properties = d
|
||||
return workout_plan_create
|
||||
|
||||
@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,44 @@
|
||||
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="WorkoutPlanCreatePlanDetails")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class WorkoutPlanCreatePlanDetails:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
workout_plan_create_plan_details = cls()
|
||||
|
||||
workout_plan_create_plan_details.additional_properties = d
|
||||
return workout_plan_create_plan_details
|
||||
|
||||
@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,44 @@
|
||||
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="WorkoutPlanPlanDetails")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class WorkoutPlanPlanDetails:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
workout_plan_plan_details = cls()
|
||||
|
||||
workout_plan_plan_details.additional_properties = d
|
||||
return workout_plan_plan_details
|
||||
|
||||
@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,89 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..models.workout_plan_update_plan_details_type_0 import WorkoutPlanUpdatePlanDetailsType0
|
||||
|
||||
|
||||
T = TypeVar("T", bound="WorkoutPlanUpdate")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class WorkoutPlanUpdate:
|
||||
"""
|
||||
Attributes:
|
||||
plan_details (Union['WorkoutPlanUpdatePlanDetailsType0', None, Unset]):
|
||||
"""
|
||||
|
||||
plan_details: Union["WorkoutPlanUpdatePlanDetailsType0", None, Unset] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
from ..models.workout_plan_update_plan_details_type_0 import WorkoutPlanUpdatePlanDetailsType0
|
||||
|
||||
plan_details: Union[None, Unset, dict[str, Any]]
|
||||
if isinstance(self.plan_details, Unset):
|
||||
plan_details = UNSET
|
||||
elif isinstance(self.plan_details, WorkoutPlanUpdatePlanDetailsType0):
|
||||
plan_details = self.plan_details.to_dict()
|
||||
else:
|
||||
plan_details = self.plan_details
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update({})
|
||||
if plan_details is not UNSET:
|
||||
field_dict["plan_details"] = plan_details
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
from ..models.workout_plan_update_plan_details_type_0 import WorkoutPlanUpdatePlanDetailsType0
|
||||
|
||||
d = dict(src_dict)
|
||||
|
||||
def _parse_plan_details(data: object) -> Union["WorkoutPlanUpdatePlanDetailsType0", None, Unset]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
plan_details_type_0 = WorkoutPlanUpdatePlanDetailsType0.from_dict(data)
|
||||
|
||||
return plan_details_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union["WorkoutPlanUpdatePlanDetailsType0", None, Unset], data)
|
||||
|
||||
plan_details = _parse_plan_details(d.pop("plan_details", UNSET))
|
||||
|
||||
workout_plan_update = cls(
|
||||
plan_details=plan_details,
|
||||
)
|
||||
|
||||
workout_plan_update.additional_properties = d
|
||||
return workout_plan_update
|
||||
|
||||
@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,44 @@
|
||||
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="WorkoutPlanUpdatePlanDetailsType0")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class WorkoutPlanUpdatePlanDetailsType0:
|
||||
""" """
|
||||
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
workout_plan_update_plan_details_type_0 = cls()
|
||||
|
||||
workout_plan_update_plan_details_type_0.additional_properties = d
|
||||
return workout_plan_update_plan_details_type_0
|
||||
|
||||
@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 @@
|
||||
# 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"]
|
||||
26
backend/src/central_db_client/pyproject.toml
Normal file
26
backend/src/central_db_client/pyproject.toml
Normal file
@@ -0,0 +1,26 @@
|
||||
[tool.poetry]
|
||||
name = "fit-track-central-db-api-client"
|
||||
version = "1.0.0"
|
||||
description = "A client library for accessing FitTrack CentralDB API"
|
||||
authors = []
|
||||
readme = "README.md"
|
||||
packages = [
|
||||
{ include = "fit_track_central_db_api_client" },
|
||||
]
|
||||
include = ["CHANGELOG.md", "fit_track_central_db_api_client/py.typed"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.9"
|
||||
httpx = ">=0.23.0,<0.29.0"
|
||||
attrs = ">=22.2.0"
|
||||
python-dateutil = "^2.8.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 120
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["F", "I", "UP"]
|
||||
56
backend/src/config.py
Normal file
56
backend/src/config.py
Normal file
@@ -0,0 +1,56 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Tuple
|
||||
import logging
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Settings(BaseSettings):
|
||||
APP_NAME: str = "GarminSync Backend"
|
||||
DEBUG: bool = False
|
||||
API_PORT: int = 8001
|
||||
SECRET_KEY: str = "your-super-secret-key"
|
||||
ALGORITHM: str = "HS256"
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
||||
SESSION_COOKIE_NAME: str = "fittrack_session"
|
||||
SESSION_COOKIE_KEY: str = "a_very_secret_key"
|
||||
GARMIN_CONNECT_EMAIL: str = ""
|
||||
GARMIN_CONNECT_PASSWORD: str = ""
|
||||
CENTRAL_DB_URL: str = "http://localhost:8000" # Default for CentralDB
|
||||
GARMINSYNC_DATA_DIR: Path = Path("data")
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
env_file_encoding = "utf-8"
|
||||
|
||||
settings = Settings()
|
||||
|
||||
# Create data directory if it doesn't exist
|
||||
# settings.GARMINSYNC_DATA_DIR.mkdir(exist_ok=True)
|
||||
|
||||
_deprecation_warned = False
|
||||
|
||||
def get_garmin_credentials() -> Tuple[str, str]:
|
||||
"""Get Garmin Connect credentials from environment variables.
|
||||
|
||||
Prefers GARMIN_CONNECT_EMAIL and GARMIN_CONNECT_PASSWORD.
|
||||
|
||||
Returns:
|
||||
Tuple of (email, password)
|
||||
|
||||
Raises:
|
||||
ValueError: If required credentials are not found
|
||||
"""
|
||||
global _deprecation_warned
|
||||
|
||||
email = settings.GARMIN_CONNECT_EMAIL
|
||||
password = settings.GARMIN_CONNECT_PASSWORD
|
||||
|
||||
if email and password:
|
||||
return email, password
|
||||
|
||||
raise ValueError(
|
||||
"Garmin credentials not found. Set GARMIN_CONNECT_EMAIL and GARMIN_CONNECT_PASSWORD "
|
||||
"environment variables."
|
||||
)
|
||||
44
backend/src/dependencies.py
Normal file
44
backend/src/dependencies.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from fastapi import Depends, HTTPException, status, Request
|
||||
|
||||
from .services.garmin_client_service import GarminClientService, garmin_client_service
|
||||
from .services.garmin_activity_service import GarminActivityService
|
||||
from .services.garmin_health_service import GarminHealthService
|
||||
from .services.garmin_workout_service import GarminWorkoutService
|
||||
from .services.sync_status_service import SyncStatusService
|
||||
from .services.central_db_service import CentralDBService
|
||||
from .services.auth_service import AuthService
|
||||
from .services.activity_download_service import ActivityDownloadService
|
||||
from .config import settings
|
||||
from .schemas import User
|
||||
from .jobs import job_store
|
||||
|
||||
def get_central_db_service() -> CentralDBService:
|
||||
return CentralDBService(base_url=settings.CENTRAL_DB_URL)
|
||||
|
||||
def get_auth_service() -> AuthService:
|
||||
return AuthService()
|
||||
|
||||
def get_activity_download_service(garmin_client_service: GarminClientService = Depends(lambda: garmin_client_service)) -> ActivityDownloadService:
|
||||
return ActivityDownloadService(garmin_client_service)
|
||||
|
||||
def get_garmin_activity_service(garmin_client_service: GarminClientService = Depends(lambda: garmin_client_service), activity_download_service: ActivityDownloadService = Depends(get_activity_download_service)) -> GarminActivityService:
|
||||
return GarminActivityService(garmin_client_service, activity_download_service)
|
||||
|
||||
def get_garmin_health_service() -> GarminHealthService:
|
||||
central_db_service = get_central_db_service()
|
||||
return GarminHealthService(garmin_client_service, central_db_service)
|
||||
|
||||
def get_garmin_workout_service() -> GarminWorkoutService:
|
||||
return GarminWorkoutService(garmin_client_service)
|
||||
|
||||
def get_sync_status_service() -> SyncStatusService:
|
||||
return SyncStatusService(job_store=job_store)
|
||||
|
||||
async def get_current_user(request: Request, auth_service: AuthService = Depends(get_auth_service)) -> User:
|
||||
user = await auth_service.get_current_user(request)
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Invalid authentication credentials",
|
||||
)
|
||||
return user
|
||||
15
backend/src/garmin_sync_backend.egg-info/PKG-INFO
Normal file
15
backend/src/garmin_sync_backend.egg-info/PKG-INFO
Normal file
@@ -0,0 +1,15 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: garmin_sync_backend
|
||||
Version: 0.1.0
|
||||
Summary: Backend service for GarminSync
|
||||
Requires-Python: >=3.10
|
||||
Requires-Dist: fastapi
|
||||
Requires-Dist: uvicorn
|
||||
Requires-Dist: garth
|
||||
Requires-Dist: garminconnect
|
||||
Requires-Dist: passlib[bcrypt]
|
||||
Requires-Dist: python-jose[jwt]
|
||||
Requires-Dist: pydantic-settings
|
||||
Requires-Dist: limits
|
||||
Requires-Dist: httpx
|
||||
Requires-Dist: tenacity
|
||||
87
backend/src/garmin_sync_backend.egg-info/SOURCES.txt
Normal file
87
backend/src/garmin_sync_backend.egg-info/SOURCES.txt
Normal file
@@ -0,0 +1,87 @@
|
||||
pyproject.toml
|
||||
src/api/garmin_sync.py
|
||||
src/central_db_client/fit_track_central_db_api_client/__init__.py
|
||||
src/central_db_client/fit_track_central_db_api_client/client.py
|
||||
src/central_db_client/fit_track_central_db_api_client/errors.py
|
||||
src/central_db_client/fit_track_central_db_api_client/py.typed
|
||||
src/central_db_client/fit_track_central_db_api_client/types.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/__init__.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/__init__.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/create_analysis_artifact_activities_activity_id_analysis_post.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/create_coaching_session_coaching_sessions_post.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/create_health_metric_health_metrics_post.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/create_user_users_post.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/create_workout_plan_workout_plans_post.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/delete_health_metric_health_metrics_metric_id_delete.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/delete_user_users_user_id_delete.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/delete_workout_plan_workout_plans_plan_id_delete.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/download_activity_file_activities_activity_id_file_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/get_activity_by_id_activities_activity_id_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/get_all_activities_activities_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/get_all_coaching_sessions_coaching_sessions_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/read_health_metric_health_metrics_metric_id_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/read_health_metrics_by_user_users_user_id_health_metrics_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/read_user_users_user_id_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/read_users_users_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/read_workout_plan_workout_plans_plan_id_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/read_workout_plans_by_user_users_user_id_workout_plans_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/update_health_metric_health_metrics_metric_id_put.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/update_user_users_user_id_put.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/update_workout_plan_workout_plans_plan_id_put.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/default/upload_activity_activities_post.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/root/__init__.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/root/read_root_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/tokens/__init__.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/tokens/create_token_api_tokens_post.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/tokens/delete_token_api_tokens_user_id_delete.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/tokens/get_token_api_tokens_user_id_get.py
|
||||
src/central_db_client/fit_track_central_db_api_client/api/tokens/update_token_api_tokens_user_id_put.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/__init__.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/activity.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/activity_activity_metadata_type_0.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/analysis_artifact.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/analysis_artifact_create.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/analysis_artifact_create_data.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/analysis_artifact_data.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/body_upload_activity_activities_post.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/coaching_session.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/coaching_session_conversation.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/coaching_session_create.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/coaching_session_create_conversation.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/health_metric.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/health_metric_create.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/health_metric_update.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/http_validation_error.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/token.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/token_create.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/token_update.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/user.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/user_create.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/user_create_preferences_type_0.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/user_preferences_type_0.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/user_update.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/user_update_preferences_type_0.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/validation_error.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/workout_plan.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/workout_plan_create.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/workout_plan_create_plan_details.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/workout_plan_plan_details.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/workout_plan_update.py
|
||||
src/central_db_client/fit_track_central_db_api_client/models/workout_plan_update_plan_details_type_0.py
|
||||
src/garmin_sync_backend.egg-info/PKG-INFO
|
||||
src/garmin_sync_backend.egg-info/SOURCES.txt
|
||||
src/garmin_sync_backend.egg-info/dependency_links.txt
|
||||
src/garmin_sync_backend.egg-info/requires.txt
|
||||
src/garmin_sync_backend.egg-info/top_level.txt
|
||||
src/services/__init__.py
|
||||
src/services/activity_download_service.py
|
||||
src/services/auth_service.py
|
||||
src/services/background_tasks.py
|
||||
src/services/central_db_service.py
|
||||
src/services/garmin_activity_service.py
|
||||
src/services/garmin_client_service.py
|
||||
src/services/garmin_health_service.py
|
||||
src/services/garmin_workout_service.py
|
||||
src/services/rate_limiter.py
|
||||
src/services/sync_status_service.py
|
||||
src/utils/file_utils.py
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
10
backend/src/garmin_sync_backend.egg-info/requires.txt
Normal file
10
backend/src/garmin_sync_backend.egg-info/requires.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
fastapi
|
||||
uvicorn
|
||||
garth
|
||||
garminconnect
|
||||
passlib[bcrypt]
|
||||
python-jose[jwt]
|
||||
pydantic-settings
|
||||
limits
|
||||
httpx
|
||||
tenacity
|
||||
4
backend/src/garmin_sync_backend.egg-info/top_level.txt
Normal file
4
backend/src/garmin_sync_backend.egg-info/top_level.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
api
|
||||
central_db_client
|
||||
services
|
||||
utils
|
||||
51
backend/src/jobs.py
Normal file
51
backend/src/jobs.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from threading import Lock
|
||||
from typing import Dict, Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class SyncJob(BaseModel):
|
||||
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
||||
status: str = "pending"
|
||||
start_time: datetime = Field(default_factory=datetime.utcnow)
|
||||
end_time: Optional[datetime] = None
|
||||
progress: float = 0.0
|
||||
error_message: Optional[str] = None
|
||||
details: Dict = Field(default_factory=dict)
|
||||
|
||||
|
||||
class JobStore:
|
||||
def __init__(self):
|
||||
self._jobs: Dict[str, SyncJob] = {}
|
||||
self._lock = Lock()
|
||||
|
||||
def create_job(self) -> SyncJob:
|
||||
job = SyncJob()
|
||||
with self._lock:
|
||||
self._jobs[job.id] = job
|
||||
return job
|
||||
|
||||
def get_job(self, job_id: str) -> Optional[SyncJob]:
|
||||
with self._lock:
|
||||
return self._jobs.get(job_id)
|
||||
|
||||
def get_all_jobs(self) -> list[SyncJob]:
|
||||
with self._lock:
|
||||
return list(self._jobs.values())
|
||||
|
||||
def update_job(self, job_id: str, status: str, progress: float, details: Optional[Dict] = None, error_message: Optional[str] = None):
|
||||
with self._lock:
|
||||
job = self._jobs.get(job_id)
|
||||
if job:
|
||||
job.status = status
|
||||
job.progress = progress
|
||||
if details:
|
||||
job.details = details
|
||||
if error_message:
|
||||
job.error_message = error_message
|
||||
if status in ["completed", "failed"]:
|
||||
job.end_time = datetime.utcnow()
|
||||
|
||||
job_store = JobStore()
|
||||
8
backend/src/logging_config.py
Normal file
8
backend/src/logging_config.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import logging
|
||||
|
||||
LOG_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||||
|
||||
def setup_logging():
|
||||
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
|
||||
# You can add more sophisticated logging handlers here, e.g., file handlers, Sentry, etc.
|
||||
|
||||
80
backend/src/main.py
Normal file
80
backend/src/main.py
Normal file
@@ -0,0 +1,80 @@
|
||||
import logging
|
||||
import uuid
|
||||
from fastapi import FastAPI, Request, status, BackgroundTasks, Depends, HTTPException, Form, Response
|
||||
from fastapi.responses import JSONResponse
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .config import settings
|
||||
from .logging_config import setup_logging
|
||||
from .services.background_tasks import example_background_task
|
||||
from .services.rate_limiter import RateLimiter
|
||||
from .services.garmin_client_service import garmin_client_service
|
||||
from .services.garmin_activity_service import GarminActivityService
|
||||
from .services.garmin_health_service import GarminHealthService # New import
|
||||
from .services.garmin_workout_service import GarminWorkoutService # New import
|
||||
from .services.sync_status_service import SyncStatusService # New import
|
||||
from .services.central_db_service import CentralDBService # New import
|
||||
from .services.auth_service import AuthService # New import
|
||||
from .dependencies import get_auth_service
|
||||
|
||||
|
||||
from .api import garmin_sync # New import for API router
|
||||
|
||||
setup_logging()
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
app = FastAPI(title=settings.APP_NAME)
|
||||
|
||||
# Initialize the rate limiter
|
||||
# Adjust the rate limit as needed, e.g., "10/minute", "100/hour"
|
||||
rate_limiter = RateLimiter(rate_limit="100/minute")
|
||||
|
||||
# Initialize CentralDBService
|
||||
central_db_service = CentralDBService(base_url=settings.CENTRAL_DB_URL) # Assuming CENTRAL_DB_URL in settings
|
||||
|
||||
app.include_router(garmin_sync.router, prefix="/api/sync", tags=["Garmin Sync"]) # Include the new router
|
||||
|
||||
@app.post("/login")
|
||||
async def login(response: Response, username: str = Form(...), password: str = Form(...), auth_service: AuthService = Depends(get_auth_service)):
|
||||
user = await auth_service.authenticate_garmin_connect(email=username, password=password)
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Incorrect username or password",
|
||||
)
|
||||
session_cookie = auth_service.create_session_cookie(user.id)
|
||||
response.set_cookie(
|
||||
key=settings.SESSION_COOKIE_NAME,
|
||||
value=session_cookie,
|
||||
httponly=True,
|
||||
max_age=settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60,
|
||||
expires=settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60,
|
||||
)
|
||||
return {"message": "Login successful"}
|
||||
|
||||
@app.post("/logout")
|
||||
async def logout(response: Response):
|
||||
response.delete_cookie(key=settings.SESSION_COOKIE_NAME)
|
||||
return {"message": "Logout successful"}
|
||||
|
||||
|
||||
@app.exception_handler(Exception)
|
||||
async def general_exception_handler(request: Request, exc: Exception):
|
||||
logger.exception(f"Unhandled exception: {exc}")
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
content={
|
||||
"message": "An unexpected error occurred.",
|
||||
"detail": str(exc) if settings.DEBUG else None, # Only show detail in debug mode
|
||||
},
|
||||
)
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "Welcome to GarminSync Backend!"}
|
||||
|
||||
@app.post("/background-test", dependencies=[Depends(rate_limiter)])
|
||||
async def run_background_test(background_tasks: BackgroundTasks):
|
||||
message = "This is a test background task."
|
||||
background_tasks.add_task(example_background_task, message)
|
||||
return {"message": "Background task initiated! Check logs for progress."}
|
||||
53
backend/src/schemas.py
Normal file
53
backend/src/schemas.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, Dict, Any
|
||||
from datetime import datetime, date
|
||||
|
||||
from .jobs import SyncJob
|
||||
|
||||
class UserBase(BaseModel):
|
||||
name: str
|
||||
email: str
|
||||
|
||||
class UserCreate(UserBase):
|
||||
pass
|
||||
|
||||
class User(UserBase):
|
||||
id: int
|
||||
preferences: Optional[Dict[str, Any]] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class TokenBase(BaseModel):
|
||||
access_token: str
|
||||
refresh_token: str
|
||||
expires_at: int # Unix timestamp
|
||||
|
||||
class TokenCreate(TokenBase):
|
||||
user_id: int
|
||||
|
||||
class TokenUpdate(TokenBase):
|
||||
user_id: int
|
||||
|
||||
class Token(TokenBase):
|
||||
id: int
|
||||
user_id: int
|
||||
created_at: datetime
|
||||
updated_at: Optional[datetime] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class WorkoutPlan(BaseModel):
|
||||
id: int
|
||||
user_id: int
|
||||
plan_details: Dict[str, Any]
|
||||
created_at: datetime
|
||||
|
||||
class ActivitySyncRequest(BaseModel):
|
||||
force_resync: bool = Field(False, description="If true, re-download activities even if they exist. Defaults to false.")
|
||||
start_date: Optional[date] = Field(None, description="Optional start date (YYYY-MM-DD) to sync activities from. If not provided, syncs recent activities.")
|
||||
end_date: Optional[date] = Field(None, description="Optional end date (YYYY-MM-DD) to sync activities up to.")
|
||||
|
||||
class WorkoutUploadRequest(BaseModel):
|
||||
workout_id: int = Field(..., description="The ID of the workout to upload from CentralDB.")
|
||||
0
backend/src/services/__init__.py
Normal file
0
backend/src/services/__init__.py
Normal file
BIN
backend/src/services/__pycache__/__init__.cpython-313.pyc
Normal file
BIN
backend/src/services/__pycache__/__init__.cpython-313.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/src/services/__pycache__/auth_service.cpython-313.pyc
Normal file
BIN
backend/src/services/__pycache__/auth_service.cpython-313.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user