Gears API reference
Gears
Gear API router endpoints.
create_gear
create_gear(request, gear, token_user_id, db, response)
Create a gear for the authenticated user; Location names where it is read.
Source code in backend/app/modules/gears/gear/router.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
delete_gear
delete_gear(request, response, gear_id, token_user_id, if_match, states, db)
Queue the deletion of one of the authenticated user's gears.
Send If-Match with the gear's version as an ETag; a stale tag is refused with 412 before anything is
queued. The gear is unassigned from its activities in the background, so the response is 202 with a job:
poll GET /jobs/{job_id} until it succeeds. The gear stays readable until then. A second delete while
one is pending is refused with 409.
Source code in backend/app/modules/gears/gear/router.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
edit_gear
edit_gear(request, gear_id, gear, token_user_id, db, response, if_match)
Update one of the authenticated user's gears.
Applies a partial update: omit a field to leave it untouched and send an explicit
null to clear a nullable one (brand, model, purchase_value).
Send If-Match with the gear's version as an ETag to make the write
conditional; a stale tag is refused with 412. Changing gear_type is refused with 409
while the gear has components that are not valid for the new type; remove them first.
Source code in backend/app/modules/gears/gear/router.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
list_gears
list_gears(token_user_id, db, page, active=None, gear_type=None, nickname_contains=None)
Retrieve one page of the authenticated user's gears, with the matching total.
Source code in backend/app/modules/gears/gear/router.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
read_gear_id
read_gear_id(gear_id, token_user_id, db, response)
Retrieve a gear by ID with its total distance, time and components cost.
Source code in backend/app/modules/gears/gear/router.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
Gear schema definitions.
GearBase
Bases: BaseModel
Fields a client may set on a gear.
Attributes:
| Name | Type | Description |
|---|---|---|
brand |
StrictStr | None
|
Gear brand name. |
model |
StrictStr | None
|
Gear model name. |
nickname |
StrictStr | None
|
Gear display nickname. |
gear_type |
StrictStr | None
|
Gear type identifier. |
acquired_on |
date | None
|
Date the user acquired the gear; today when a gear is created without one. |
active |
StrictBool | None
|
Whether the gear is active. |
initial_distance |
StrictFloat | None
|
Distance the gear had before it was tracked, in meters. |
purchase_value |
Money | None
|
Purchase price as a decimal string in the owner's currency. |
Source code in backend/app/modules/gears/gear/schema.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
GearCreate
Bases: GearStored
A gear to create, as built by the provider syncs and the profile import.
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
UUID | None
|
Foreign key to user; ignored on write, the owner is passed explicitly. |
Source code in backend/app/modules/gears/gear/schema.py
198 199 200 201 202 203 204 205 206 207 208 | |
GearCreateRequest
Bases: GearBase
Request body for creating a gear.
Provider gear IDs are not accepted: only the Strava and Garmin Connect syncs and the profile import set them, so a client cannot forge a provider link.
Source code in backend/app/modules/gears/gear/schema.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
GearDeletionStatus
Bases: JobStatusOpenFailure
Where a queued gear deletion is.
Source code in backend/app/modules/gears/gear/schema.py
292 293 294 295 | |
GearDetailRead
Bases: GearRead
Extended gear with computed stats.
Attributes:
| Name | Type | Description |
|---|---|---|
total_distance |
StrictFloat
|
Total distance (m). |
total_time |
StrictFloat
|
Total time (seconds). |
total_components_cost |
MoneyTotal
|
Sum of the component purchase values as a decimal string in the owner's currency. |
Source code in backend/app/modules/gears/gear/schema.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
GearRead
Bases: GearStored
Schema for reading a gear record.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
Unique identifier. |
user_id |
UUID
|
Foreign key to user. |
version |
StrictInt
|
Optimistic-concurrency counter, also sent as the |
updated_at |
datetime
|
When the gear last changed; set by the server. |
Source code in backend/app/modules/gears/gear/schema.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
GearStored
Bases: GearBase
The fields a stored gear always has: a nickname, a type and the provider gear IDs.
Attributes:
| Name | Type | Description |
|---|---|---|
strava_gear_id |
StrictStr | None
|
Strava gear ID. |
garminconnect_gear_id |
StrictStr | None
|
Garmin Connect gear ID. |
Source code in backend/app/modules/gears/gear/schema.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
GearType
Bases: StoredStrEnum
Supported gear types; stored is the integer in gears.gear_type.
Attributes:
| Name | Type | Description |
|---|---|---|
BIKE |
Bicycle. |
|
SHOES |
Running or walking shoes. |
|
WETSUIT |
Wetsuit. |
|
RACQUET |
Racquet. |
|
SKI |
Skis. |
|
SNOWBOARD |
Snowboard. |
|
WINDSURF |
Windsurf board. |
|
WATER_SPORTS_BOARD |
Water sports board. |
Source code in backend/app/modules/gears/gear/schema.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
GearUpdate
Bases: NotClearable, GearBase
Partial update of a gear: omit a field to keep it, send null to clear a nullable one.
The gear comes from the path; provider gear IDs cannot be changed.
Source code in backend/app/modules/gears/gear/schema.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
normalize_nickname
normalize_nickname(nickname)
Normalize a nickname for case-insensitive comparison.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nickname
|
str
|
The nickname to compare. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The nickname trimmed and lower-cased, as the unique index compares it. |
Source code in backend/app/modules/gears/gear/schema.py
78 79 80 81 82 83 84 85 86 87 | |
Gear components
Gear components API router endpoints.
create_gear_component
create_gear_component(request, gear_component, token_user_id, db, response)
Create a component on one of the authenticated user's gears; Location names where it is read.
Source code in backend/app/modules/gears/gear_components/router.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
delete_component_gear
delete_component_gear(request, gear_component_id, token_user_id, if_match, db)
Delete one of the authenticated user's gear components.
Send If-Match with the component's version as an ETag; a stale tag is refused with 412.
Source code in backend/app/modules/gears/gear_components/router.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
edit_gear_component
edit_gear_component(request, gear_component_id, gear_component, token_user_id, db, response, if_match)
Update one of the authenticated user's gear components.
Applies a partial update: only fields present in the request body are
changed, so omit a field to leave it untouched and send an explicit
null to clear a nullable field (e.g. retired_date).
The retired/active invariant is enforced server-side: while
retired_date is set the component is always inactive (active is
forced to false); while it is null the submitted active value is
honoured. Reactivating a retired component therefore requires clearing
retired_date and setting active to true in the same request.
Send If-Match with the component's version as an ETag to make the write
conditional; a stale tag is refused with 412.
Source code in backend/app/modules/gears/gear_components/router.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
read_gear_component_by_id
read_gear_component_by_id(gear_component_id, token_user_id, db, response)
Retrieve one of the authenticated user's gear components; its ETag is the version for If-Match.
Source code in backend/app/modules/gears/gear_components/router.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
read_gear_component_types
read_gear_component_types()
Retrieve the valid component types, grouped by gear type.
Source code in backend/app/modules/gears/gear_components/router.py
17 18 19 20 21 22 23 24 | |
read_gear_components
read_gear_components(token_user_id, db, page)
Retrieve one page of the authenticated user's gear components, with the total.
Source code in backend/app/modules/gears/gear_components/router.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
Gear components schema definitions.
GearComponentBase
Bases: BaseModel
Base model for the gear component fields a client may set.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Type of gear component. |
|
brand |
Gear component brand. |
|
model |
Gear component model name. |
|
purchase_date |
date | None
|
Purchase date (calendar date, no time of day). |
retired_date |
date | None
|
Retired date (calendar date, no time of day). |
active |
StrictBool | None
|
Whether component is active. |
expected_usage |
StrictInt | None
|
Wear threshold in meters for a distance-tracked gear and in seconds for a time-tracked one. |
purchase_value |
Money | None
|
Purchase price as a decimal string in the owner's currency. |
Source code in backend/app/modules/gears/gear_components/schema.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
GearComponentCreate
Bases: GearComponentBase
Schema for creating a gear component.
Attributes:
| Name | Type | Description |
|---|---|---|
gear_id |
UUID
|
Foreign key to gear table. |
Source code in backend/app/modules/gears/gear_components/schema.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
GearComponentRead
Bases: GearComponentCreate
Schema for reading a gear component.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
Unique identifier. |
user_id |
UUID
|
Foreign key to user. |
version |
StrictInt
|
Optimistic-concurrency counter, also sent as the |
updated_at |
datetime
|
When the component last changed; set by the server. |
Source code in backend/app/modules/gears/gear_components/schema.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
GearComponentTypesRead
Bases: BaseModel
Schema for reading component type lists.
Attributes:
| Name | Type | Description |
|---|---|---|
bike |
list[str]
|
Valid bike component types. |
shoes |
list[str]
|
Valid shoes component types. |
racquet |
list[str]
|
Valid racquet component types. |
windsurf |
list[str]
|
Valid windsurf component types. |
Source code in backend/app/modules/gears/gear_components/schema.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
GearComponentUpdate
Bases: NotClearable, GearComponentBase
Partial update of a gear component: omit a field to keep it, send null to clear a nullable one.
The component and its gear come from the path and cannot be changed.
Source code in backend/app/modules/gears/gear_components/schema.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
GearComponentUsageRead
Bases: GearComponentRead
A gear component with the usage it has accumulated, served by the per-gear list only.
Attributes:
| Name | Type | Description |
|---|---|---|
current_distance |
StrictFloat
|
Accumulated distance in meters. |
current_time |
StrictFloat
|
Accumulated time in seconds. |
Source code in backend/app/modules/gears/gear_components/schema.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
is_retired_after_purchase
is_retired_after_purchase(purchase_date, retired_date)
Whether a retired date is acceptable next to a purchase date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
purchase_date
|
date | None
|
The purchase date, if given. |
required |
retired_date
|
date | None
|
The retired date, if given. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
False only when both are given and the retired date is not later. |
Source code in backend/app/modules/gears/gear_components/schema.py
23 24 25 26 27 28 29 30 31 32 33 | |