diff --git a/schema/wger-openapi.yaml b/schema/wger-openapi.yaml index 3667882..3a63ccb 100644 --- a/schema/wger-openapi.yaml +++ b/schema/wger-openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: title: wger - version: 2.7.0a2 + version: 2.7.0 description: | Self hosted FLOSS workout and fitness tracker. @@ -2973,31 +2973,6 @@ paths: schema: $ref: '#/components/schemas/IngredientWeightUnit' description: '' - /api/v2/issue-refresh-token: - post: - operationId: issue_refresh_token_create - description: |- - Temporary endpoint for issuing refresh tokens for authenticated users. - - This endpoint is used to allow users of the mobile app to seamlessly move from - permanent tokens to JWT ones. - - TODO: remove one version after the iniial offline-mode release - tags: - - issue-refresh-token - security: - - cookieAuth: [] - - tokenAuth: [] - - headlessJwtAuth: [] - - oidcAuth: [] - - jwtAuth: [] - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/RefreshTokenResponse' - description: '' /api/v2/language/: get: operationId: language_list @@ -4731,6 +4706,20 @@ paths: description: Which field to use when ordering the results. schema: type: string + - in: query + name: source + schema: + type: string + enum: + - apple + - calculated + - google + - user + description: |- + * `user` - User + * `google` - Google + * `apple` - Apple + * `calculated` - Calculated tags: - measurement security: @@ -4780,12 +4769,62 @@ paths: schema: type: string format: uuid + - in: query + name: is_official + schema: + type: boolean - name: limit required: false in: query description: Number of results to return per page. schema: type: integer + - in: query + name: metric_type + schema: + type: string + enum: + - blood_oxygen + - blood_pressure + - blood_pressure_diastolic + - blood_pressure_systolic + - body_fat + - body_weight + - custom + - distance + - energy + - heart_rate + - height + - lean_body_mass + - resting_heart_rate + - sleep + - sleep_awake + - sleep_deep + - sleep_light + - sleep_rem + - sleep_total + - steps + description: |- + * `custom` - Custom + * `body_weight` - Body Weight + * `body_fat` - Body Fat + * `lean_body_mass` - Lean Body Mass + * `height` - Height + * `blood_pressure` - Blood Pressure + * `blood_pressure_systolic` - Blood Pressure Systolic + * `blood_pressure_diastolic` - Blood Pressure Diastolic + * `heart_rate` - Heart Rate + * `resting_heart_rate` - Resting Heart Rate + * `blood_oxygen` - Blood Oxygen + * `steps` - Steps + * `distance` - Distance + * `energy` - Energy + * `sleep` - Sleep + * `sleep_total` - Total sleep + * `sleep_light` - Light sleep + * `sleep_deep` - Deep sleep + * `sleep_rem` - REM sleep + * `sleep_awake` - Awake - in: query name: name schema: @@ -4802,6 +4841,11 @@ paths: description: Which field to use when ordering the results. schema: type: string + - in: query + name: parent + schema: + type: string + format: uuid - in: query name: unit schema: @@ -4957,6 +5001,30 @@ paths: responses: '204': description: No response body + /api/v2/measurement-category/dynamic-types/: + get: + operationId: measurement_category_dynamic_types_list + description: |- + The calculated types a category can be switched to, with the schema + their dynamic_params have to match + summary: Read the available calculated category types + tags: + - measurement-category + security: + - cookieAuth: [] + - tokenAuth: [] + - headlessJwtAuth: [] + - oidcAuth: [] + - jwtAuth: [] + responses: + '200': + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/DynamicType' + description: '' /api/v2/measurement/{id}/: get: operationId: measurement_retrieve @@ -5069,6 +5137,250 @@ paths: responses: '204': description: No response body + /api/v2/measurement/aggregate/: + get: + operationId: measurement_aggregate_list + description: |- + The entries condensed into what a chart draws: one row per category, + calendar bucket and stored unit. + + Takes the filters of the list endpoint (`category`, `category__in`, + `date__gte`, ...) plus `bucket` (`auto`, the default, or one of hour, + day, week, month), `tz` and `max_points`. A separate route rather than + a mode of the list, because a bucket is not a measurement: it has no + id, and nothing that reads measurements should have to tell them apart. + summary: Read the entries condensed into chart points + parameters: + - in: query + name: bucket + schema: + type: string + enum: + - auto + - day + - hour + - month + - week + description: Calendar unit to condense into. The default picks the finest + one that keeps the series under max_points. + - in: query + name: category + schema: + type: string + format: uuid + - in: query + name: category__in + schema: + type: array + items: + type: string + format: uuid + description: Multiple values may be separated by commas. + explode: false + style: form + - in: query + name: date + schema: + type: string + format: date-time + - in: query + name: date__gt + schema: + type: string + format: date-time + - in: query + name: date__gte + schema: + type: string + format: date-time + - in: query + name: date__lt + schema: + type: string + format: date-time + - in: query + name: date__lte + schema: + type: string + format: date-time + - in: query + name: id + schema: + type: string + format: uuid + - in: query + name: id__in + schema: + type: array + items: + type: string + format: uuid + description: Multiple values may be separated by commas. + explode: false + style: form + - in: query + name: max_points + schema: + type: integer + description: Points the auto bucket aims for, 200 by default + - name: ordering + required: false + in: query + description: Which field to use when ordering the results. + schema: + type: string + - in: query + name: source + schema: + type: string + enum: + - apple + - calculated + - google + - user + description: |- + * `user` - User + * `google` - Google + * `apple` - Apple + * `calculated` - Calculated + - in: query + name: tz + schema: + type: string + description: IANA name of the zone the buckets are cut in, the server zone + by default. The column is UTC, and a reading after midnight belongs to the + day the user had it. + tags: + - measurement + security: + - cookieAuth: [] + - tokenAuth: [] + - headlessJwtAuth: [] + - oidcAuth: [] + - jwtAuth: [] + responses: + '200': + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Bucket' + description: '' + /api/v2/measurement/value-counts/: + get: + operationId: measurement_value_counts_list + description: |- + How often each value occurred, which is what a histogram bins. + + Takes the same filters, plus `tz` and `summed_per_day` for the metrics + whose samples mean nothing on their own (steps, sleep), which are + counted as daily totals instead. + summary: Read how often each value occurred + parameters: + - in: query + name: category + schema: + type: string + format: uuid + - in: query + name: category__in + schema: + type: array + items: + type: string + format: uuid + description: Multiple values may be separated by commas. + explode: false + style: form + - in: query + name: date + schema: + type: string + format: date-time + - in: query + name: date__gt + schema: + type: string + format: date-time + - in: query + name: date__gte + schema: + type: string + format: date-time + - in: query + name: date__lt + schema: + type: string + format: date-time + - in: query + name: date__lte + schema: + type: string + format: date-time + - in: query + name: id + schema: + type: string + format: uuid + - in: query + name: id__in + schema: + type: array + items: + type: string + format: uuid + description: Multiple values may be separated by commas. + explode: false + style: form + - name: ordering + required: false + in: query + description: Which field to use when ordering the results. + schema: + type: string + - in: query + name: source + schema: + type: string + enum: + - apple + - calculated + - google + - user + description: |- + * `user` - User + * `google` - Google + * `apple` - Apple + * `calculated` - Calculated + - in: query + name: summed_per_day + schema: + type: boolean + description: Count daily totals rather than single readings, for the metrics + whose samples mean nothing on their own (steps, sleep) + - in: query + name: tz + schema: + type: string + description: IANA name of the zone the days are cut in + tags: + - measurement + security: + - cookieAuth: [] + - tokenAuth: [] + - headlessJwtAuth: [] + - oidcAuth: [] + - jwtAuth: [] + responses: + '200': + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ValueCount' + description: '' /api/v2/min-app-version/: get: operationId: min_app_version_retrieve @@ -9130,7 +9442,7 @@ paths: /api/v2/weightentry/: get: operationId: weightentry_list - description: API endpoint for nutrition plan objects + description: API endpoint for weight entry objects parameters: - in: query name: date @@ -9160,13 +9472,15 @@ paths: - in: query name: id schema: - type: integer + type: string + format: uuid - in: query name: id__in schema: type: array items: - type: integer + type: string + format: uuid description: Multiple values may be separated by commas. explode: false style: form @@ -9225,7 +9539,7 @@ paths: description: '' post: operationId: weightentry_create - description: API endpoint for nutrition plan objects + description: API endpoint for weight entry objects tags: - weightentry requestBody: @@ -9250,13 +9564,14 @@ paths: /api/v2/weightentry/{id}/: get: operationId: weightentry_retrieve - description: API endpoint for nutrition plan objects + description: API endpoint for weight entry objects parameters: - in: path name: id schema: - type: integer - description: A unique integer value identifying this Weight entry. + type: string + format: uuid + description: A UUID string identifying this measurement. required: true tags: - weightentry @@ -9275,13 +9590,14 @@ paths: description: '' put: operationId: weightentry_update - description: API endpoint for nutrition plan objects + description: API endpoint for weight entry objects parameters: - in: path name: id schema: - type: integer - description: A unique integer value identifying this Weight entry. + type: string + format: uuid + description: A UUID string identifying this measurement. required: true tags: - weightentry @@ -9306,13 +9622,14 @@ paths: description: '' patch: operationId: weightentry_partial_update - description: API endpoint for nutrition plan objects + description: API endpoint for weight entry objects parameters: - in: path name: id schema: - type: integer - description: A unique integer value identifying this Weight entry. + type: string + format: uuid + description: A UUID string identifying this measurement. required: true tags: - weightentry @@ -9336,13 +9653,14 @@ paths: description: '' delete: operationId: weightentry_destroy - description: API endpoint for nutrition plan objects + description: API endpoint for weight entry objects parameters: - in: path name: id schema: - type: integer - description: A unique integer value identifying this Weight entry. + type: string + format: uuid + description: A UUID string identifying this measurement. required: true tags: - weightentry @@ -9764,10 +10082,69 @@ paths: description: API endpoint for workout sessions objects parameters: - in: query - name: date + name: datetime_end + schema: + type: string + format: date-time + - in: query + name: datetime_end__date + schema: + type: string + format: date + - in: query + name: datetime_end__gt + schema: + type: string + format: date-time + - in: query + name: datetime_end__gte + schema: + type: string + format: date-time + - in: query + name: datetime_end__lt + schema: + type: string + format: date-time + - in: query + name: datetime_end__lte + schema: + type: string + format: date-time + - in: query + name: datetime_start + schema: + type: string + format: date-time + - in: query + name: datetime_start__date schema: type: string format: date + - in: query + name: datetime_start__gt + schema: + type: string + format: date-time + - in: query + name: datetime_start__gte + schema: + type: string + format: date-time + - in: query + name: datetime_start__lt + schema: + type: string + format: date-time + - in: query + name: datetime_start__lte + schema: + type: string + format: date-time + - in: query + name: day + schema: + type: integer - in: query name: impression schema: @@ -9809,16 +10186,6 @@ paths: name: routine schema: type: integer - - in: query - name: time_end - schema: - type: string - format: time - - in: query - name: time_start - schema: - type: string - format: time tags: - workoutsession security: @@ -9973,6 +10340,51 @@ components: BlankEnum: enum: - '' + Bucket: + type: object + description: |- + One calendar bucket of a category's entries, see `api.aggregates`. + + Read-only: buckets are derived, there is nothing to write back. + properties: + category: + type: string + format: uuid + readOnly: true + start: + type: string + format: date-time + readOnly: true + unit: + type: string + readOnly: true + nullable: true + count: + type: integer + readOnly: true + sum: + type: string + format: decimal + pattern: ^-?\d{0,8}(?:\.\d{0,2})?$ + readOnly: true + min: + type: string + format: decimal + pattern: ^-?\d{0,8}(?:\.\d{0,2})?$ + readOnly: true + max: + type: string + format: decimal + pattern: ^-?\d{0,8}(?:\.\d{0,2})?$ + readOnly: true + required: + - category + - count + - max + - min + - start + - sum + - unit Category: type: object description: Measurement category serializer @@ -9986,9 +10398,34 @@ components: unit: type: string maxLength: 30 + metric_type: + $ref: '#/components/schemas/MetricTypeEnum' + chart_type: + nullable: true + oneOf: + - $ref: '#/components/schemas/ChartTypeEnum' + - $ref: '#/components/schemas/BlankEnum' + - $ref: '#/components/schemas/NullEnum' + chart_config: {} + parent: + type: string + format: uuid + nullable: true + order: + type: integer + maximum: 2147483647 + minimum: -2147483648 + is_official: + type: boolean + readOnly: true + title: Official category + dynamic_type: + $ref: '#/components/schemas/DynamicTypeEnum' + dynamic_params: + description: Configuration parameters for dynamic calculations required: + - is_official - name - - unit CategoryRequest: type: object description: Measurement category serializer @@ -10002,11 +10439,44 @@ components: maxLength: 100 unit: type: string - minLength: 1 maxLength: 30 + metric_type: + $ref: '#/components/schemas/MetricTypeEnum' + chart_type: + nullable: true + oneOf: + - $ref: '#/components/schemas/ChartTypeEnum' + - $ref: '#/components/schemas/BlankEnum' + - $ref: '#/components/schemas/NullEnum' + chart_config: {} + parent: + type: string + format: uuid + nullable: true + order: + type: integer + maximum: 2147483647 + minimum: -2147483648 + dynamic_type: + $ref: '#/components/schemas/DynamicTypeEnum' + dynamic_params: + description: Configuration parameters for dynamic calculations required: - name - - unit + ChartTypeEnum: + enum: + - line + - bar + - heatmap + - delta + - distribution + type: string + description: |- + * `line` - Line + * `bar` - Bar + * `heatmap` - Heatmap + * `delta` - Delta + * `distribution` - Distribution CursorPaginatedIngredientInfoList: type: object required: @@ -10166,6 +10636,38 @@ components: - replaced_by - timestamp - uuid + DynamicType: + type: object + description: |- + One calculated category type of the registry. Read-only: the registry is + code, there is nothing to write back. + properties: + value: + type: string + readOnly: true + label: + type: string + readOnly: true + params_schema: + readOnly: true + required: + - label + - params_schema + - value + DynamicTypeEnum: + enum: + - NONE + - BMI + - WHTR + - ONE_REP_MAX + - ONE_RM_TOTAL + type: string + description: |- + * `NONE` - None + * `BMI` - BMI + * `WHTR` - Waist-to-height ratio + * `ONE_REP_MAX` - 1RM + * `ONE_RM_TOTAL` - 1RM total Equipment: type: object description: Equipment serializer @@ -12654,12 +13156,22 @@ components: value: type: number format: double - maximum: 5000 + maximum: 1000000 minimum: 0 + exclusiveMaximum: true notes: type: string title: Description maxLength: 100 + source: + allOf: + - $ref: '#/components/schemas/SourceEnum' + default: user + external_id: + type: string + format: uuid + nullable: true + extra_data: {} required: - category - value @@ -12679,15 +13191,69 @@ components: value: type: number format: double - maximum: 5000 + maximum: 1000000 minimum: 0 + exclusiveMaximum: true notes: type: string title: Description maxLength: 100 + source: + allOf: + - $ref: '#/components/schemas/SourceEnum' + default: user + external_id: + type: string + format: uuid + nullable: true + extra_data: {} required: - category - value + MetricTypeEnum: + enum: + - custom + - body_weight + - body_fat + - lean_body_mass + - height + - blood_pressure + - blood_pressure_systolic + - blood_pressure_diastolic + - heart_rate + - resting_heart_rate + - blood_oxygen + - steps + - distance + - energy + - sleep + - sleep_total + - sleep_light + - sleep_deep + - sleep_rem + - sleep_awake + type: string + description: |- + * `custom` - Custom + * `body_weight` - Body Weight + * `body_fat` - Body Fat + * `lean_body_mass` - Lean Body Mass + * `height` - Height + * `blood_pressure` - Blood Pressure + * `blood_pressure_systolic` - Blood Pressure Systolic + * `blood_pressure_diastolic` - Blood Pressure Diastolic + * `heart_rate` - Heart Rate + * `resting_heart_rate` - Resting Heart Rate + * `blood_oxygen` - Blood Oxygen + * `steps` - Steps + * `distance` - Distance + * `energy` - Energy + * `sleep` - Sleep + * `sleep_total` - Total sleep + * `sleep_light` - Light sleep + * `sleep_deep` - Deep sleep + * `sleep_rem` - REM sleep + * `sleep_awake` - Awake ModelTypeEnum: enum: - base @@ -14056,8 +14622,28 @@ components: maxLength: 100 unit: type: string - minLength: 1 maxLength: 30 + metric_type: + $ref: '#/components/schemas/MetricTypeEnum' + chart_type: + nullable: true + oneOf: + - $ref: '#/components/schemas/ChartTypeEnum' + - $ref: '#/components/schemas/BlankEnum' + - $ref: '#/components/schemas/NullEnum' + chart_config: {} + parent: + type: string + format: uuid + nullable: true + order: + type: integer + maximum: 2147483647 + minimum: -2147483648 + dynamic_type: + $ref: '#/components/schemas/DynamicTypeEnum' + dynamic_params: + description: Configuration parameters for dynamic calculations PatchedDayRequest: type: object description: Day serializer @@ -14483,12 +15069,21 @@ components: value: type: number format: double - maximum: 5000 + maximum: 1000000 minimum: 0 + exclusiveMaximum: true notes: type: string title: Description maxLength: 100 + source: + allOf: + - $ref: '#/components/schemas/SourceEnum' + external_id: + type: string + format: uuid + nullable: true + extra_data: {} PatchedNutritionPlanRequest: type: object description: Nutritional plan serializer @@ -14851,6 +15446,12 @@ components: minimum: 0 title: Automatic reminders for weight entries description: Number of days after the last weight entry (enter 0 to deactivate) + time_zone: + type: string + title: Timezone + description: IANA timezone name, e.g. "Europe/Berlin". Empty means no client + has reported one and the instance timezone is used. + maxLength: 50 PatchedWeightConfigRequest: type: object description: Weight Config serializer @@ -14877,13 +15478,16 @@ components: type: object description: Weight serializer properties: + id: + type: string + format: uuid date: type: string format: date-time weight: type: string format: decimal - pattern: ^-?\d{0,3}(?:\.\d{0,2})?$ + pattern: ^-?\d{0,6}(?:\.\d{0,2})?$ PatchedWorkoutLogRequest: type: object description: Workout log serializer @@ -14975,9 +15579,6 @@ components: day: type: integer nullable: true - date: - type: string - format: date notes: type: string nullable: true @@ -14992,16 +15593,15 @@ components: * `1` - Bad * `2` - Neutral * `3` - Good - time_start: + datetime_start: type: string - format: time - nullable: true - title: Start time - time_end: + format: date-time + title: Start date and time + datetime_end: type: string - format: time + format: date-time nullable: true - title: Finish time + title: End date and time PermissionResponse: type: object properties: @@ -15048,13 +15648,6 @@ components: type: string details: type: string - RefreshTokenResponse: - type: object - properties: - refresh_token: - type: string - required: - - refresh_token RepetitionUnit: type: object description: Repetition unit serializer @@ -15792,6 +16385,18 @@ components: - day - entries - id + SourceEnum: + enum: + - user + - google + - apple + - calculated + type: string + description: |- + * `user` - User + * `google` - Google + * `apple` - Apple + * `calculated` - Calculated StepEnum: enum: - na @@ -16298,6 +16903,12 @@ components: minimum: 0 title: Automatic reminders for weight entries description: Number of days after the last weight entry (enter 0 to deactivate) + time_zone: + type: string + title: Timezone + description: IANA timezone name, e.g. "Europe/Berlin". Empty means no client + has reported one and the instance timezone is used. + maxLength: 50 required: - date_joined - email @@ -16445,6 +17056,44 @@ components: minimum: 0 title: Automatic reminders for weight entries description: Number of days after the last weight entry (enter 0 to deactivate) + time_zone: + type: string + title: Timezone + description: IANA timezone name, e.g. "Europe/Berlin". Empty means no client + has reported one and the instance timezone is used. + maxLength: 50 + ValueCount: + type: object + description: |- + How often one value occurred, and when it was measured last. Read-only for + the same reason as `BucketSerializer`. + properties: + category: + type: string + format: uuid + readOnly: true + value: + type: string + format: decimal + pattern: ^-?\d{0,6}(?:\.\d{0,2})?$ + readOnly: true + unit: + type: string + readOnly: true + nullable: true + count: + type: integer + readOnly: true + newest: + type: string + format: date-time + readOnly: true + required: + - category + - count + - newest + - unit + - value VerifyEmailResponse: type: object properties: @@ -16517,36 +17166,36 @@ components: description: Weight serializer properties: id: - type: integer - readOnly: true + type: string + format: uuid date: type: string format: date-time weight: type: string format: decimal - pattern: ^-?\d{0,3}(?:\.\d{0,2})?$ + pattern: ^-?\d{0,6}(?:\.\d{0,2})?$ user: type: integer readOnly: true required: - - date - - id - user - weight WeightEntryRequest: type: object description: Weight serializer properties: + id: + type: string + format: uuid date: type: string format: date-time weight: type: string format: decimal - pattern: ^-?\d{0,3}(?:\.\d{0,2})?$ + pattern: ^-?\d{0,6}(?:\.\d{0,2})?$ required: - - date - weight WeightUnitEnum: enum: @@ -16775,9 +17424,6 @@ components: day: type: integer nullable: true - date: - type: string - format: date notes: type: string nullable: true @@ -16792,16 +17438,15 @@ components: * `1` - Bad * `2` - Neutral * `3` - Good - time_start: + datetime_start: type: string - format: time - nullable: true - title: Start time - time_end: + format: date-time + title: Start date and time + datetime_end: type: string - format: time + format: date-time nullable: true - title: Finish time + title: End date and time WorkoutSessionRequest: type: object description: Workout session serializer @@ -16815,9 +17460,6 @@ components: day: type: integer nullable: true - date: - type: string - format: date notes: type: string nullable: true @@ -16832,16 +17474,15 @@ components: * `1` - Bad * `2` - Neutral * `3` - Good - time_start: + datetime_start: type: string - format: time - nullable: true - title: Start time - time_end: + format: date-time + title: Start date and time + datetime_end: type: string - format: time + format: date-time nullable: true - title: Finish time + title: End date and time securitySchemes: cookieAuth: type: apiKey @@ -16861,8 +17502,8 @@ components: description: Access token issued by the OAuth2/OIDC provider flows: authorizationCode: - authorizationUrl: /identity/o/authorize - tokenUrl: /identity/o/api/token + authorizationUrl: https://wger.de/identity/o/authorize + tokenUrl: https://wger.de/identity/o/api/token scopes: api:read: View your training, nutrition and body data api:write: Add and change your training, nutrition and body data diff --git a/wger_api_client/api/issue_refresh_token/__init__.py b/wger_api_client/api/issue_refresh_token/__init__.py deleted file mode 100644 index 2d7c0b2..0000000 --- a/wger_api_client/api/issue_refresh_token/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Contains endpoint functions for accessing the API""" diff --git a/wger_api_client/api/measurement/measurement_aggregate_list.py b/wger_api_client/api/measurement/measurement_aggregate_list.py new file mode 100644 index 0000000..0e190b0 --- /dev/null +++ b/wger_api_client/api/measurement/measurement_aggregate_list.py @@ -0,0 +1,441 @@ +import datetime +from http import HTTPStatus +from typing import Any +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.bucket import Bucket +from ...models.measurement_aggregate_list_bucket import ( + MeasurementAggregateListBucket, +) +from ...models.measurement_aggregate_list_source import ( + MeasurementAggregateListSource, +) +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + bucket: MeasurementAggregateListBucket | Unset = UNSET, + category: UUID | Unset = UNSET, + category_in: list[UUID] | Unset = UNSET, + date: datetime.datetime | Unset = UNSET, + date_gt: datetime.datetime | Unset = UNSET, + date_gte: datetime.datetime | Unset = UNSET, + date_lt: datetime.datetime | Unset = UNSET, + date_lte: datetime.datetime | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, + max_points: int | Unset = UNSET, + ordering: str | Unset = UNSET, + source: MeasurementAggregateListSource | Unset = UNSET, + tz: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + json_bucket: str | Unset = UNSET + if not isinstance(bucket, Unset): + json_bucket = bucket + + params["bucket"] = json_bucket + + json_category: str | Unset = UNSET + if not isinstance(category, Unset): + json_category = str(category) + params["category"] = json_category + + json_category_in: str | Unset = UNSET + if not isinstance(category_in, Unset): + json_category_in = ",".join(str(v) for v in category_in) + + params["category__in"] = json_category_in + + json_date: str | Unset = UNSET + if not isinstance(date, Unset): + json_date = date.isoformat() + params["date"] = json_date + + json_date_gt: str | Unset = UNSET + if not isinstance(date_gt, Unset): + json_date_gt = date_gt.isoformat() + params["date__gt"] = json_date_gt + + json_date_gte: str | Unset = UNSET + if not isinstance(date_gte, Unset): + json_date_gte = date_gte.isoformat() + params["date__gte"] = json_date_gte + + json_date_lt: str | Unset = UNSET + if not isinstance(date_lt, Unset): + json_date_lt = date_lt.isoformat() + params["date__lt"] = json_date_lt + + json_date_lte: str | Unset = UNSET + if not isinstance(date_lte, Unset): + json_date_lte = date_lte.isoformat() + params["date__lte"] = json_date_lte + + json_id: str | Unset = UNSET + if not isinstance(id, Unset): + json_id = str(id) + params["id"] = json_id + + json_id_in: str | Unset = UNSET + if not isinstance(id_in, Unset): + json_id_in = ",".join(str(v) for v in id_in) + + params["id__in"] = json_id_in + + params["max_points"] = max_points + + params["ordering"] = ordering + + json_source: str | Unset = UNSET + if not isinstance(source, Unset): + json_source = source + + params["source"] = json_source + + params["tz"] = tz + + 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": "/api/v2/measurement/aggregate/", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[Bucket] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = Bucket.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: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[Bucket]]: + 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: AuthenticatedClient, + bucket: MeasurementAggregateListBucket | Unset = UNSET, + category: UUID | Unset = UNSET, + category_in: list[UUID] | Unset = UNSET, + date: datetime.datetime | Unset = UNSET, + date_gt: datetime.datetime | Unset = UNSET, + date_gte: datetime.datetime | Unset = UNSET, + date_lt: datetime.datetime | Unset = UNSET, + date_lte: datetime.datetime | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, + max_points: int | Unset = UNSET, + ordering: str | Unset = UNSET, + source: MeasurementAggregateListSource | Unset = UNSET, + tz: str | Unset = UNSET, +) -> Response[list[Bucket]]: + """Read the entries condensed into chart points + + The entries condensed into what a chart draws: one row per category, + calendar bucket and stored unit. + + Takes the filters of the list endpoint (`category`, `category__in`, + `date__gte`, ...) plus `bucket` (`auto`, the default, or one of hour, + day, week, month), `tz` and `max_points`. A separate route rather than + a mode of the list, because a bucket is not a measurement: it has no + id, and nothing that reads measurements should have to tell them apart. + + Args: + bucket (MeasurementAggregateListBucket | Unset): + category (UUID | Unset): + category_in (list[UUID] | Unset): + date (datetime.datetime | Unset): + date_gt (datetime.datetime | Unset): + date_gte (datetime.datetime | Unset): + date_lt (datetime.datetime | Unset): + date_lte (datetime.datetime | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): + max_points (int | Unset): + ordering (str | Unset): + source (MeasurementAggregateListSource | Unset): + tz (str | Unset): + + 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[Bucket]] + """ + + kwargs = _get_kwargs( + bucket=bucket, + category=category, + category_in=category_in, + date=date, + date_gt=date_gt, + date_gte=date_gte, + date_lt=date_lt, + date_lte=date_lte, + id=id, + id_in=id_in, + max_points=max_points, + ordering=ordering, + source=source, + tz=tz, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, + bucket: MeasurementAggregateListBucket | Unset = UNSET, + category: UUID | Unset = UNSET, + category_in: list[UUID] | Unset = UNSET, + date: datetime.datetime | Unset = UNSET, + date_gt: datetime.datetime | Unset = UNSET, + date_gte: datetime.datetime | Unset = UNSET, + date_lt: datetime.datetime | Unset = UNSET, + date_lte: datetime.datetime | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, + max_points: int | Unset = UNSET, + ordering: str | Unset = UNSET, + source: MeasurementAggregateListSource | Unset = UNSET, + tz: str | Unset = UNSET, +) -> list[Bucket] | None: + """Read the entries condensed into chart points + + The entries condensed into what a chart draws: one row per category, + calendar bucket and stored unit. + + Takes the filters of the list endpoint (`category`, `category__in`, + `date__gte`, ...) plus `bucket` (`auto`, the default, or one of hour, + day, week, month), `tz` and `max_points`. A separate route rather than + a mode of the list, because a bucket is not a measurement: it has no + id, and nothing that reads measurements should have to tell them apart. + + Args: + bucket (MeasurementAggregateListBucket | Unset): + category (UUID | Unset): + category_in (list[UUID] | Unset): + date (datetime.datetime | Unset): + date_gt (datetime.datetime | Unset): + date_gte (datetime.datetime | Unset): + date_lt (datetime.datetime | Unset): + date_lte (datetime.datetime | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): + max_points (int | Unset): + ordering (str | Unset): + source (MeasurementAggregateListSource | Unset): + tz (str | Unset): + + 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[Bucket] + """ + + return sync_detailed( + client=client, + bucket=bucket, + category=category, + category_in=category_in, + date=date, + date_gt=date_gt, + date_gte=date_gte, + date_lt=date_lt, + date_lte=date_lte, + id=id, + id_in=id_in, + max_points=max_points, + ordering=ordering, + source=source, + tz=tz, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, + bucket: MeasurementAggregateListBucket | Unset = UNSET, + category: UUID | Unset = UNSET, + category_in: list[UUID] | Unset = UNSET, + date: datetime.datetime | Unset = UNSET, + date_gt: datetime.datetime | Unset = UNSET, + date_gte: datetime.datetime | Unset = UNSET, + date_lt: datetime.datetime | Unset = UNSET, + date_lte: datetime.datetime | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, + max_points: int | Unset = UNSET, + ordering: str | Unset = UNSET, + source: MeasurementAggregateListSource | Unset = UNSET, + tz: str | Unset = UNSET, +) -> Response[list[Bucket]]: + """Read the entries condensed into chart points + + The entries condensed into what a chart draws: one row per category, + calendar bucket and stored unit. + + Takes the filters of the list endpoint (`category`, `category__in`, + `date__gte`, ...) plus `bucket` (`auto`, the default, or one of hour, + day, week, month), `tz` and `max_points`. A separate route rather than + a mode of the list, because a bucket is not a measurement: it has no + id, and nothing that reads measurements should have to tell them apart. + + Args: + bucket (MeasurementAggregateListBucket | Unset): + category (UUID | Unset): + category_in (list[UUID] | Unset): + date (datetime.datetime | Unset): + date_gt (datetime.datetime | Unset): + date_gte (datetime.datetime | Unset): + date_lt (datetime.datetime | Unset): + date_lte (datetime.datetime | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): + max_points (int | Unset): + ordering (str | Unset): + source (MeasurementAggregateListSource | Unset): + tz (str | Unset): + + 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[Bucket]] + """ + + kwargs = _get_kwargs( + bucket=bucket, + category=category, + category_in=category_in, + date=date, + date_gt=date_gt, + date_gte=date_gte, + date_lt=date_lt, + date_lte=date_lte, + id=id, + id_in=id_in, + max_points=max_points, + ordering=ordering, + source=source, + tz=tz, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, + bucket: MeasurementAggregateListBucket | Unset = UNSET, + category: UUID | Unset = UNSET, + category_in: list[UUID] | Unset = UNSET, + date: datetime.datetime | Unset = UNSET, + date_gt: datetime.datetime | Unset = UNSET, + date_gte: datetime.datetime | Unset = UNSET, + date_lt: datetime.datetime | Unset = UNSET, + date_lte: datetime.datetime | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, + max_points: int | Unset = UNSET, + ordering: str | Unset = UNSET, + source: MeasurementAggregateListSource | Unset = UNSET, + tz: str | Unset = UNSET, +) -> list[Bucket] | None: + """Read the entries condensed into chart points + + The entries condensed into what a chart draws: one row per category, + calendar bucket and stored unit. + + Takes the filters of the list endpoint (`category`, `category__in`, + `date__gte`, ...) plus `bucket` (`auto`, the default, or one of hour, + day, week, month), `tz` and `max_points`. A separate route rather than + a mode of the list, because a bucket is not a measurement: it has no + id, and nothing that reads measurements should have to tell them apart. + + Args: + bucket (MeasurementAggregateListBucket | Unset): + category (UUID | Unset): + category_in (list[UUID] | Unset): + date (datetime.datetime | Unset): + date_gt (datetime.datetime | Unset): + date_gte (datetime.datetime | Unset): + date_lt (datetime.datetime | Unset): + date_lte (datetime.datetime | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): + max_points (int | Unset): + ordering (str | Unset): + source (MeasurementAggregateListSource | Unset): + tz (str | Unset): + + 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[Bucket] + """ + + return ( + await asyncio_detailed( + client=client, + bucket=bucket, + category=category, + category_in=category_in, + date=date, + date_gt=date_gt, + date_gte=date_gte, + date_lt=date_lt, + date_lte=date_lte, + id=id, + id_in=id_in, + max_points=max_points, + ordering=ordering, + source=source, + tz=tz, + ) + ).parsed diff --git a/wger_api_client/api/measurement/measurement_list.py b/wger_api_client/api/measurement/measurement_list.py index 38600d9..4aa0f64 100644 --- a/wger_api_client/api/measurement/measurement_list.py +++ b/wger_api_client/api/measurement/measurement_list.py @@ -7,6 +7,9 @@ from ... import errors from ...client import AuthenticatedClient, Client +from ...models.measurement_list_source import ( + MeasurementListSource, +) from ...models.paginated_measurement_list import PaginatedMeasurementList from ...types import UNSET, Response, Unset @@ -25,6 +28,7 @@ def _get_kwargs( limit: int | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, + source: MeasurementListSource | Unset = UNSET, ) -> dict[str, Any]: params: dict[str, Any] = {} @@ -82,6 +86,12 @@ def _get_kwargs( params["ordering"] = ordering + json_source: str | Unset = UNSET + if not isinstance(source, Unset): + json_source = source + + params["source"] = json_source + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} _kwargs: dict[str, Any] = { @@ -133,6 +143,7 @@ def sync_detailed( limit: int | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, + source: MeasurementListSource | Unset = UNSET, ) -> Response[PaginatedMeasurementList]: """API endpoint for measurements @@ -149,6 +160,7 @@ def sync_detailed( limit (int | Unset): offset (int | Unset): ordering (str | Unset): + source (MeasurementListSource | Unset): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -171,6 +183,7 @@ def sync_detailed( limit=limit, offset=offset, ordering=ordering, + source=source, ) response = client.get_httpx_client().request( @@ -195,6 +208,7 @@ def sync( limit: int | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, + source: MeasurementListSource | Unset = UNSET, ) -> PaginatedMeasurementList | None: """API endpoint for measurements @@ -211,6 +225,7 @@ def sync( limit (int | Unset): offset (int | Unset): ordering (str | Unset): + source (MeasurementListSource | Unset): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -234,6 +249,7 @@ def sync( limit=limit, offset=offset, ordering=ordering, + source=source, ).parsed @@ -252,6 +268,7 @@ async def asyncio_detailed( limit: int | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, + source: MeasurementListSource | Unset = UNSET, ) -> Response[PaginatedMeasurementList]: """API endpoint for measurements @@ -268,6 +285,7 @@ async def asyncio_detailed( limit (int | Unset): offset (int | Unset): ordering (str | Unset): + source (MeasurementListSource | Unset): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -290,6 +308,7 @@ async def asyncio_detailed( limit=limit, offset=offset, ordering=ordering, + source=source, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -312,6 +331,7 @@ async def asyncio( limit: int | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, + source: MeasurementListSource | Unset = UNSET, ) -> PaginatedMeasurementList | None: """API endpoint for measurements @@ -328,6 +348,7 @@ async def asyncio( limit (int | Unset): offset (int | Unset): ordering (str | Unset): + source (MeasurementListSource | Unset): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -352,5 +373,6 @@ async def asyncio( limit=limit, offset=offset, ordering=ordering, + source=source, ) ).parsed diff --git a/wger_api_client/api/measurement/measurement_value_counts_list.py b/wger_api_client/api/measurement/measurement_value_counts_list.py new file mode 100644 index 0000000..1bc5cfe --- /dev/null +++ b/wger_api_client/api/measurement/measurement_value_counts_list.py @@ -0,0 +1,407 @@ +import datetime +from http import HTTPStatus +from typing import Any +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.measurement_value_counts_list_source import ( + MeasurementValueCountsListSource, +) +from ...models.value_count import ValueCount +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + category: UUID | Unset = UNSET, + category_in: list[UUID] | Unset = UNSET, + date: datetime.datetime | Unset = UNSET, + date_gt: datetime.datetime | Unset = UNSET, + date_gte: datetime.datetime | Unset = UNSET, + date_lt: datetime.datetime | Unset = UNSET, + date_lte: datetime.datetime | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, + ordering: str | Unset = UNSET, + source: MeasurementValueCountsListSource | Unset = UNSET, + summed_per_day: bool | Unset = UNSET, + tz: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + json_category: str | Unset = UNSET + if not isinstance(category, Unset): + json_category = str(category) + params["category"] = json_category + + json_category_in: str | Unset = UNSET + if not isinstance(category_in, Unset): + json_category_in = ",".join(str(v) for v in category_in) + + params["category__in"] = json_category_in + + json_date: str | Unset = UNSET + if not isinstance(date, Unset): + json_date = date.isoformat() + params["date"] = json_date + + json_date_gt: str | Unset = UNSET + if not isinstance(date_gt, Unset): + json_date_gt = date_gt.isoformat() + params["date__gt"] = json_date_gt + + json_date_gte: str | Unset = UNSET + if not isinstance(date_gte, Unset): + json_date_gte = date_gte.isoformat() + params["date__gte"] = json_date_gte + + json_date_lt: str | Unset = UNSET + if not isinstance(date_lt, Unset): + json_date_lt = date_lt.isoformat() + params["date__lt"] = json_date_lt + + json_date_lte: str | Unset = UNSET + if not isinstance(date_lte, Unset): + json_date_lte = date_lte.isoformat() + params["date__lte"] = json_date_lte + + json_id: str | Unset = UNSET + if not isinstance(id, Unset): + json_id = str(id) + params["id"] = json_id + + json_id_in: str | Unset = UNSET + if not isinstance(id_in, Unset): + json_id_in = ",".join(str(v) for v in id_in) + + params["id__in"] = json_id_in + + params["ordering"] = ordering + + json_source: str | Unset = UNSET + if not isinstance(source, Unset): + json_source = source + + params["source"] = json_source + + params["summed_per_day"] = summed_per_day + + params["tz"] = tz + + 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": "/api/v2/measurement/value-counts/", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[ValueCount] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = ValueCount.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: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[ValueCount]]: + 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: AuthenticatedClient, + category: UUID | Unset = UNSET, + category_in: list[UUID] | Unset = UNSET, + date: datetime.datetime | Unset = UNSET, + date_gt: datetime.datetime | Unset = UNSET, + date_gte: datetime.datetime | Unset = UNSET, + date_lt: datetime.datetime | Unset = UNSET, + date_lte: datetime.datetime | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, + ordering: str | Unset = UNSET, + source: MeasurementValueCountsListSource | Unset = UNSET, + summed_per_day: bool | Unset = UNSET, + tz: str | Unset = UNSET, +) -> Response[list[ValueCount]]: + """Read how often each value occurred + + How often each value occurred, which is what a histogram bins. + + Takes the same filters, plus `tz` and `summed_per_day` for the metrics + whose samples mean nothing on their own (steps, sleep), which are + counted as daily totals instead. + + Args: + category (UUID | Unset): + category_in (list[UUID] | Unset): + date (datetime.datetime | Unset): + date_gt (datetime.datetime | Unset): + date_gte (datetime.datetime | Unset): + date_lt (datetime.datetime | Unset): + date_lte (datetime.datetime | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): + ordering (str | Unset): + source (MeasurementValueCountsListSource | Unset): + summed_per_day (bool | Unset): + tz (str | Unset): + + 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[ValueCount]] + """ + + kwargs = _get_kwargs( + category=category, + category_in=category_in, + date=date, + date_gt=date_gt, + date_gte=date_gte, + date_lt=date_lt, + date_lte=date_lte, + id=id, + id_in=id_in, + ordering=ordering, + source=source, + summed_per_day=summed_per_day, + tz=tz, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, + category: UUID | Unset = UNSET, + category_in: list[UUID] | Unset = UNSET, + date: datetime.datetime | Unset = UNSET, + date_gt: datetime.datetime | Unset = UNSET, + date_gte: datetime.datetime | Unset = UNSET, + date_lt: datetime.datetime | Unset = UNSET, + date_lte: datetime.datetime | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, + ordering: str | Unset = UNSET, + source: MeasurementValueCountsListSource | Unset = UNSET, + summed_per_day: bool | Unset = UNSET, + tz: str | Unset = UNSET, +) -> list[ValueCount] | None: + """Read how often each value occurred + + How often each value occurred, which is what a histogram bins. + + Takes the same filters, plus `tz` and `summed_per_day` for the metrics + whose samples mean nothing on their own (steps, sleep), which are + counted as daily totals instead. + + Args: + category (UUID | Unset): + category_in (list[UUID] | Unset): + date (datetime.datetime | Unset): + date_gt (datetime.datetime | Unset): + date_gte (datetime.datetime | Unset): + date_lt (datetime.datetime | Unset): + date_lte (datetime.datetime | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): + ordering (str | Unset): + source (MeasurementValueCountsListSource | Unset): + summed_per_day (bool | Unset): + tz (str | Unset): + + 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[ValueCount] + """ + + return sync_detailed( + client=client, + category=category, + category_in=category_in, + date=date, + date_gt=date_gt, + date_gte=date_gte, + date_lt=date_lt, + date_lte=date_lte, + id=id, + id_in=id_in, + ordering=ordering, + source=source, + summed_per_day=summed_per_day, + tz=tz, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, + category: UUID | Unset = UNSET, + category_in: list[UUID] | Unset = UNSET, + date: datetime.datetime | Unset = UNSET, + date_gt: datetime.datetime | Unset = UNSET, + date_gte: datetime.datetime | Unset = UNSET, + date_lt: datetime.datetime | Unset = UNSET, + date_lte: datetime.datetime | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, + ordering: str | Unset = UNSET, + source: MeasurementValueCountsListSource | Unset = UNSET, + summed_per_day: bool | Unset = UNSET, + tz: str | Unset = UNSET, +) -> Response[list[ValueCount]]: + """Read how often each value occurred + + How often each value occurred, which is what a histogram bins. + + Takes the same filters, plus `tz` and `summed_per_day` for the metrics + whose samples mean nothing on their own (steps, sleep), which are + counted as daily totals instead. + + Args: + category (UUID | Unset): + category_in (list[UUID] | Unset): + date (datetime.datetime | Unset): + date_gt (datetime.datetime | Unset): + date_gte (datetime.datetime | Unset): + date_lt (datetime.datetime | Unset): + date_lte (datetime.datetime | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): + ordering (str | Unset): + source (MeasurementValueCountsListSource | Unset): + summed_per_day (bool | Unset): + tz (str | Unset): + + 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[ValueCount]] + """ + + kwargs = _get_kwargs( + category=category, + category_in=category_in, + date=date, + date_gt=date_gt, + date_gte=date_gte, + date_lt=date_lt, + date_lte=date_lte, + id=id, + id_in=id_in, + ordering=ordering, + source=source, + summed_per_day=summed_per_day, + tz=tz, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, + category: UUID | Unset = UNSET, + category_in: list[UUID] | Unset = UNSET, + date: datetime.datetime | Unset = UNSET, + date_gt: datetime.datetime | Unset = UNSET, + date_gte: datetime.datetime | Unset = UNSET, + date_lt: datetime.datetime | Unset = UNSET, + date_lte: datetime.datetime | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, + ordering: str | Unset = UNSET, + source: MeasurementValueCountsListSource | Unset = UNSET, + summed_per_day: bool | Unset = UNSET, + tz: str | Unset = UNSET, +) -> list[ValueCount] | None: + """Read how often each value occurred + + How often each value occurred, which is what a histogram bins. + + Takes the same filters, plus `tz` and `summed_per_day` for the metrics + whose samples mean nothing on their own (steps, sleep), which are + counted as daily totals instead. + + Args: + category (UUID | Unset): + category_in (list[UUID] | Unset): + date (datetime.datetime | Unset): + date_gt (datetime.datetime | Unset): + date_gte (datetime.datetime | Unset): + date_lt (datetime.datetime | Unset): + date_lte (datetime.datetime | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): + ordering (str | Unset): + source (MeasurementValueCountsListSource | Unset): + summed_per_day (bool | Unset): + tz (str | Unset): + + 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[ValueCount] + """ + + return ( + await asyncio_detailed( + client=client, + category=category, + category_in=category_in, + date=date, + date_gt=date_gt, + date_gte=date_gte, + date_lt=date_lt, + date_lte=date_lte, + id=id, + id_in=id_in, + ordering=ordering, + source=source, + summed_per_day=summed_per_day, + tz=tz, + ) + ).parsed diff --git a/wger_api_client/api/issue_refresh_token/issue_refresh_token_create.py b/wger_api_client/api/measurement_category/measurement_category_dynamic_types_list.py similarity index 61% rename from wger_api_client/api/issue_refresh_token/issue_refresh_token_create.py rename to wger_api_client/api/measurement_category/measurement_category_dynamic_types_list.py index 9d51188..8d08161 100644 --- a/wger_api_client/api/issue_refresh_token/issue_refresh_token_create.py +++ b/wger_api_client/api/measurement_category/measurement_category_dynamic_types_list.py @@ -5,15 +5,15 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.refresh_token_response import RefreshTokenResponse +from ...models.dynamic_type import DynamicType from ...types import Response def _get_kwargs() -> dict[str, Any]: _kwargs: dict[str, Any] = { - "method": "post", - "url": "/api/v2/issue-refresh-token", + "method": "get", + "url": "/api/v2/measurement-category/dynamic-types/", } return _kwargs @@ -21,9 +21,14 @@ def _get_kwargs() -> dict[str, Any]: def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> RefreshTokenResponse | None: +) -> list[DynamicType] | None: if response.status_code == 200: - response_200 = RefreshTokenResponse.from_dict(response.json()) + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = DynamicType.from_dict(response_200_item_data) + + response_200.append(response_200_item) return response_200 @@ -35,7 +40,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[RefreshTokenResponse]: +) -> Response[list[DynamicType]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -47,20 +52,18 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient, -) -> Response[RefreshTokenResponse]: - """Temporary endpoint for issuing refresh tokens for authenticated users. - - This endpoint is used to allow users of the mobile app to seamlessly move from - permanent tokens to JWT ones. +) -> Response[list[DynamicType]]: + """Read the available calculated category types - TODO: remove one version after the iniial offline-mode release + The calculated types a category can be switched to, with the schema + their dynamic_params have to match 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[RefreshTokenResponse] + Response[list[DynamicType]] """ kwargs = _get_kwargs() @@ -75,20 +78,18 @@ def sync_detailed( def sync( *, client: AuthenticatedClient, -) -> RefreshTokenResponse | None: - """Temporary endpoint for issuing refresh tokens for authenticated users. - - This endpoint is used to allow users of the mobile app to seamlessly move from - permanent tokens to JWT ones. +) -> list[DynamicType] | None: + """Read the available calculated category types - TODO: remove one version after the iniial offline-mode release + The calculated types a category can be switched to, with the schema + their dynamic_params have to match 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: - RefreshTokenResponse + list[DynamicType] """ return sync_detailed( @@ -99,20 +100,18 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient, -) -> Response[RefreshTokenResponse]: - """Temporary endpoint for issuing refresh tokens for authenticated users. +) -> Response[list[DynamicType]]: + """Read the available calculated category types - This endpoint is used to allow users of the mobile app to seamlessly move from - permanent tokens to JWT ones. - - TODO: remove one version after the iniial offline-mode release + The calculated types a category can be switched to, with the schema + their dynamic_params have to match 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[RefreshTokenResponse] + Response[list[DynamicType]] """ kwargs = _get_kwargs() @@ -125,20 +124,18 @@ async def asyncio_detailed( async def asyncio( *, client: AuthenticatedClient, -) -> RefreshTokenResponse | None: - """Temporary endpoint for issuing refresh tokens for authenticated users. - - This endpoint is used to allow users of the mobile app to seamlessly move from - permanent tokens to JWT ones. +) -> list[DynamicType] | None: + """Read the available calculated category types - TODO: remove one version after the iniial offline-mode release + The calculated types a category can be switched to, with the schema + their dynamic_params have to match 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: - RefreshTokenResponse + list[DynamicType] """ return ( diff --git a/wger_api_client/api/measurement_category/measurement_category_list.py b/wger_api_client/api/measurement_category/measurement_category_list.py index 6c8e14f..c0a6c47 100644 --- a/wger_api_client/api/measurement_category/measurement_category_list.py +++ b/wger_api_client/api/measurement_category/measurement_category_list.py @@ -6,6 +6,9 @@ from ... import errors from ...client import AuthenticatedClient, Client +from ...models.measurement_category_list_metric_type import ( + MeasurementCategoryListMetricType, +) from ...models.paginated_category_list import PaginatedCategoryList from ...types import UNSET, Response, Unset @@ -13,10 +16,13 @@ def _get_kwargs( *, id: UUID | Unset = UNSET, + is_official: bool | Unset = UNSET, limit: int | Unset = UNSET, + metric_type: MeasurementCategoryListMetricType | Unset = UNSET, name: str | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, + parent: UUID | Unset = UNSET, unit: str | Unset = UNSET, ) -> dict[str, Any]: @@ -27,14 +33,27 @@ def _get_kwargs( json_id = str(id) params["id"] = json_id + params["is_official"] = is_official + params["limit"] = limit + json_metric_type: str | Unset = UNSET + if not isinstance(metric_type, Unset): + json_metric_type = metric_type + + params["metric_type"] = json_metric_type + params["name"] = name params["offset"] = offset params["ordering"] = ordering + json_parent: str | Unset = UNSET + if not isinstance(parent, Unset): + json_parent = str(parent) + params["parent"] = json_parent + params["unit"] = unit params = {k: v for k, v in params.items() if v is not UNSET and v is not None} @@ -77,20 +96,26 @@ def sync_detailed( *, client: AuthenticatedClient, id: UUID | Unset = UNSET, + is_official: bool | Unset = UNSET, limit: int | Unset = UNSET, + metric_type: MeasurementCategoryListMetricType | Unset = UNSET, name: str | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, + parent: UUID | Unset = UNSET, unit: str | Unset = UNSET, ) -> Response[PaginatedCategoryList]: """API endpoint for measurement units Args: id (UUID | Unset): + is_official (bool | Unset): limit (int | Unset): + metric_type (MeasurementCategoryListMetricType | Unset): name (str | Unset): offset (int | Unset): ordering (str | Unset): + parent (UUID | Unset): unit (str | Unset): Raises: @@ -103,10 +128,13 @@ def sync_detailed( kwargs = _get_kwargs( id=id, + is_official=is_official, limit=limit, + metric_type=metric_type, name=name, offset=offset, ordering=ordering, + parent=parent, unit=unit, ) @@ -121,20 +149,26 @@ def sync( *, client: AuthenticatedClient, id: UUID | Unset = UNSET, + is_official: bool | Unset = UNSET, limit: int | Unset = UNSET, + metric_type: MeasurementCategoryListMetricType | Unset = UNSET, name: str | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, + parent: UUID | Unset = UNSET, unit: str | Unset = UNSET, ) -> PaginatedCategoryList | None: """API endpoint for measurement units Args: id (UUID | Unset): + is_official (bool | Unset): limit (int | Unset): + metric_type (MeasurementCategoryListMetricType | Unset): name (str | Unset): offset (int | Unset): ordering (str | Unset): + parent (UUID | Unset): unit (str | Unset): Raises: @@ -148,10 +182,13 @@ def sync( return sync_detailed( client=client, id=id, + is_official=is_official, limit=limit, + metric_type=metric_type, name=name, offset=offset, ordering=ordering, + parent=parent, unit=unit, ).parsed @@ -160,20 +197,26 @@ async def asyncio_detailed( *, client: AuthenticatedClient, id: UUID | Unset = UNSET, + is_official: bool | Unset = UNSET, limit: int | Unset = UNSET, + metric_type: MeasurementCategoryListMetricType | Unset = UNSET, name: str | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, + parent: UUID | Unset = UNSET, unit: str | Unset = UNSET, ) -> Response[PaginatedCategoryList]: """API endpoint for measurement units Args: id (UUID | Unset): + is_official (bool | Unset): limit (int | Unset): + metric_type (MeasurementCategoryListMetricType | Unset): name (str | Unset): offset (int | Unset): ordering (str | Unset): + parent (UUID | Unset): unit (str | Unset): Raises: @@ -186,10 +229,13 @@ async def asyncio_detailed( kwargs = _get_kwargs( id=id, + is_official=is_official, limit=limit, + metric_type=metric_type, name=name, offset=offset, ordering=ordering, + parent=parent, unit=unit, ) @@ -202,20 +248,26 @@ async def asyncio( *, client: AuthenticatedClient, id: UUID | Unset = UNSET, + is_official: bool | Unset = UNSET, limit: int | Unset = UNSET, + metric_type: MeasurementCategoryListMetricType | Unset = UNSET, name: str | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, + parent: UUID | Unset = UNSET, unit: str | Unset = UNSET, ) -> PaginatedCategoryList | None: """API endpoint for measurement units Args: id (UUID | Unset): + is_official (bool | Unset): limit (int | Unset): + metric_type (MeasurementCategoryListMetricType | Unset): name (str | Unset): offset (int | Unset): ordering (str | Unset): + parent (UUID | Unset): unit (str | Unset): Raises: @@ -230,10 +282,13 @@ async def asyncio( await asyncio_detailed( client=client, id=id, + is_official=is_official, limit=limit, + metric_type=metric_type, name=name, offset=offset, ordering=ordering, + parent=parent, unit=unit, ) ).parsed diff --git a/wger_api_client/api/weightentry/weightentry_create.py b/wger_api_client/api/weightentry/weightentry_create.py index abc70b2..b8a6bba 100644 --- a/wger_api_client/api/weightentry/weightentry_create.py +++ b/wger_api_client/api/weightentry/weightentry_create.py @@ -59,7 +59,7 @@ def sync_detailed( client: AuthenticatedClient, body: WeightEntryRequest, ) -> Response[WeightEntry]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: body (WeightEntryRequest): Weight serializer @@ -88,7 +88,7 @@ def sync( client: AuthenticatedClient, body: WeightEntryRequest, ) -> WeightEntry | None: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: body (WeightEntryRequest): Weight serializer @@ -112,7 +112,7 @@ async def asyncio_detailed( client: AuthenticatedClient, body: WeightEntryRequest, ) -> Response[WeightEntry]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: body (WeightEntryRequest): Weight serializer @@ -139,7 +139,7 @@ async def asyncio( client: AuthenticatedClient, body: WeightEntryRequest, ) -> WeightEntry | None: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: body (WeightEntryRequest): Weight serializer diff --git a/wger_api_client/api/weightentry/weightentry_destroy.py b/wger_api_client/api/weightentry/weightentry_destroy.py index 1fa6d52..7679664 100644 --- a/wger_api_client/api/weightentry/weightentry_destroy.py +++ b/wger_api_client/api/weightentry/weightentry_destroy.py @@ -1,6 +1,7 @@ from http import HTTPStatus from typing import Any from urllib.parse import quote +from uuid import UUID import httpx @@ -10,7 +11,7 @@ def _get_kwargs( - id: int, + id: UUID, ) -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -47,14 +48,14 @@ def _build_response( def sync_detailed( - id: int, + id: UUID, *, client: AuthenticatedClient, ) -> Response[Any]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -76,14 +77,14 @@ def sync_detailed( async def asyncio_detailed( - id: int, + id: UUID, *, client: AuthenticatedClient, ) -> Response[Any]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/wger_api_client/api/weightentry/weightentry_list.py b/wger_api_client/api/weightentry/weightentry_list.py index 1994a53..06c0846 100644 --- a/wger_api_client/api/weightentry/weightentry_list.py +++ b/wger_api_client/api/weightentry/weightentry_list.py @@ -1,6 +1,7 @@ import datetime from http import HTTPStatus from typing import Any +from uuid import UUID import httpx @@ -17,8 +18,8 @@ def _get_kwargs( date_gte: datetime.datetime | Unset = UNSET, date_lt: datetime.datetime | Unset = UNSET, date_lte: datetime.datetime | Unset = UNSET, - id: int | Unset = UNSET, - id_in: list[int] | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, limit: int | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, @@ -56,7 +57,10 @@ def _get_kwargs( json_date_lte = date_lte.isoformat() params["date__lte"] = json_date_lte - params["id"] = id + json_id: str | Unset = UNSET + if not isinstance(id, Unset): + json_id = str(id) + params["id"] = json_id json_id_in: str | Unset = UNSET if not isinstance(id_in, Unset): @@ -124,8 +128,8 @@ def sync_detailed( date_gte: datetime.datetime | Unset = UNSET, date_lt: datetime.datetime | Unset = UNSET, date_lte: datetime.datetime | Unset = UNSET, - id: int | Unset = UNSET, - id_in: list[int] | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, limit: int | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, @@ -135,7 +139,7 @@ def sync_detailed( weight_lt: float | Unset = UNSET, weight_lte: float | Unset = UNSET, ) -> Response[PaginatedWeightEntryList]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: date (datetime.datetime | Unset): @@ -143,8 +147,8 @@ def sync_detailed( date_gte (datetime.datetime | Unset): date_lt (datetime.datetime | Unset): date_lte (datetime.datetime | Unset): - id (int | Unset): - id_in (list[int] | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): limit (int | Unset): offset (int | Unset): ordering (str | Unset): @@ -195,8 +199,8 @@ def sync( date_gte: datetime.datetime | Unset = UNSET, date_lt: datetime.datetime | Unset = UNSET, date_lte: datetime.datetime | Unset = UNSET, - id: int | Unset = UNSET, - id_in: list[int] | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, limit: int | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, @@ -206,7 +210,7 @@ def sync( weight_lt: float | Unset = UNSET, weight_lte: float | Unset = UNSET, ) -> PaginatedWeightEntryList | None: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: date (datetime.datetime | Unset): @@ -214,8 +218,8 @@ def sync( date_gte (datetime.datetime | Unset): date_lt (datetime.datetime | Unset): date_lte (datetime.datetime | Unset): - id (int | Unset): - id_in (list[int] | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): limit (int | Unset): offset (int | Unset): ordering (str | Unset): @@ -261,8 +265,8 @@ async def asyncio_detailed( date_gte: datetime.datetime | Unset = UNSET, date_lt: datetime.datetime | Unset = UNSET, date_lte: datetime.datetime | Unset = UNSET, - id: int | Unset = UNSET, - id_in: list[int] | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, limit: int | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, @@ -272,7 +276,7 @@ async def asyncio_detailed( weight_lt: float | Unset = UNSET, weight_lte: float | Unset = UNSET, ) -> Response[PaginatedWeightEntryList]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: date (datetime.datetime | Unset): @@ -280,8 +284,8 @@ async def asyncio_detailed( date_gte (datetime.datetime | Unset): date_lt (datetime.datetime | Unset): date_lte (datetime.datetime | Unset): - id (int | Unset): - id_in (list[int] | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): limit (int | Unset): offset (int | Unset): ordering (str | Unset): @@ -330,8 +334,8 @@ async def asyncio( date_gte: datetime.datetime | Unset = UNSET, date_lt: datetime.datetime | Unset = UNSET, date_lte: datetime.datetime | Unset = UNSET, - id: int | Unset = UNSET, - id_in: list[int] | Unset = UNSET, + id: UUID | Unset = UNSET, + id_in: list[UUID] | Unset = UNSET, limit: int | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, @@ -341,7 +345,7 @@ async def asyncio( weight_lt: float | Unset = UNSET, weight_lte: float | Unset = UNSET, ) -> PaginatedWeightEntryList | None: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: date (datetime.datetime | Unset): @@ -349,8 +353,8 @@ async def asyncio( date_gte (datetime.datetime | Unset): date_lt (datetime.datetime | Unset): date_lte (datetime.datetime | Unset): - id (int | Unset): - id_in (list[int] | Unset): + id (UUID | Unset): + id_in (list[UUID] | Unset): limit (int | Unset): offset (int | Unset): ordering (str | Unset): diff --git a/wger_api_client/api/weightentry/weightentry_partial_update.py b/wger_api_client/api/weightentry/weightentry_partial_update.py index e163232..884d35d 100644 --- a/wger_api_client/api/weightentry/weightentry_partial_update.py +++ b/wger_api_client/api/weightentry/weightentry_partial_update.py @@ -1,6 +1,7 @@ from http import HTTPStatus from typing import Any from urllib.parse import quote +from uuid import UUID import httpx @@ -12,7 +13,7 @@ def _get_kwargs( - id: int, + id: UUID, *, body: PatchedWeightEntryRequest | Unset = UNSET, ) -> dict[str, Any]: @@ -60,15 +61,15 @@ def _build_response( def sync_detailed( - id: int, + id: UUID, *, client: AuthenticatedClient, body: PatchedWeightEntryRequest | Unset = UNSET, ) -> Response[WeightEntry]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): body (PatchedWeightEntryRequest | Unset): Weight serializer Raises: @@ -92,15 +93,15 @@ def sync_detailed( def sync( - id: int, + id: UUID, *, client: AuthenticatedClient, body: PatchedWeightEntryRequest | Unset = UNSET, ) -> WeightEntry | None: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): body (PatchedWeightEntryRequest | Unset): Weight serializer Raises: @@ -119,15 +120,15 @@ def sync( async def asyncio_detailed( - id: int, + id: UUID, *, client: AuthenticatedClient, body: PatchedWeightEntryRequest | Unset = UNSET, ) -> Response[WeightEntry]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): body (PatchedWeightEntryRequest | Unset): Weight serializer Raises: @@ -149,15 +150,15 @@ async def asyncio_detailed( async def asyncio( - id: int, + id: UUID, *, client: AuthenticatedClient, body: PatchedWeightEntryRequest | Unset = UNSET, ) -> WeightEntry | None: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): body (PatchedWeightEntryRequest | Unset): Weight serializer Raises: diff --git a/wger_api_client/api/weightentry/weightentry_retrieve.py b/wger_api_client/api/weightentry/weightentry_retrieve.py index c95a38b..492f676 100644 --- a/wger_api_client/api/weightentry/weightentry_retrieve.py +++ b/wger_api_client/api/weightentry/weightentry_retrieve.py @@ -1,6 +1,7 @@ from http import HTTPStatus from typing import Any from urllib.parse import quote +from uuid import UUID import httpx @@ -11,7 +12,7 @@ def _get_kwargs( - id: int, + id: UUID, ) -> dict[str, Any]: _kwargs: dict[str, Any] = { @@ -50,14 +51,14 @@ def _build_response( def sync_detailed( - id: int, + id: UUID, *, client: AuthenticatedClient, ) -> Response[WeightEntry]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -79,14 +80,14 @@ def sync_detailed( def sync( - id: int, + id: UUID, *, client: AuthenticatedClient, ) -> WeightEntry | None: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -103,14 +104,14 @@ def sync( async def asyncio_detailed( - id: int, + id: UUID, *, client: AuthenticatedClient, ) -> Response[WeightEntry]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -130,14 +131,14 @@ async def asyncio_detailed( async def asyncio( - id: int, + id: UUID, *, client: AuthenticatedClient, ) -> WeightEntry | None: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/wger_api_client/api/weightentry/weightentry_update.py b/wger_api_client/api/weightentry/weightentry_update.py index 153d264..368e1d6 100644 --- a/wger_api_client/api/weightentry/weightentry_update.py +++ b/wger_api_client/api/weightentry/weightentry_update.py @@ -1,6 +1,7 @@ from http import HTTPStatus from typing import Any from urllib.parse import quote +from uuid import UUID import httpx @@ -12,7 +13,7 @@ def _get_kwargs( - id: int, + id: UUID, *, body: WeightEntryRequest, ) -> dict[str, Any]: @@ -59,15 +60,15 @@ def _build_response( def sync_detailed( - id: int, + id: UUID, *, client: AuthenticatedClient, body: WeightEntryRequest, ) -> Response[WeightEntry]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): body (WeightEntryRequest): Weight serializer Raises: @@ -91,15 +92,15 @@ def sync_detailed( def sync( - id: int, + id: UUID, *, client: AuthenticatedClient, body: WeightEntryRequest, ) -> WeightEntry | None: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): body (WeightEntryRequest): Weight serializer Raises: @@ -118,15 +119,15 @@ def sync( async def asyncio_detailed( - id: int, + id: UUID, *, client: AuthenticatedClient, body: WeightEntryRequest, ) -> Response[WeightEntry]: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): body (WeightEntryRequest): Weight serializer Raises: @@ -148,15 +149,15 @@ async def asyncio_detailed( async def asyncio( - id: int, + id: UUID, *, client: AuthenticatedClient, body: WeightEntryRequest, ) -> WeightEntry | None: - """API endpoint for nutrition plan objects + """API endpoint for weight entry objects Args: - id (int): + id (UUID): body (WeightEntryRequest): Weight serializer Raises: diff --git a/wger_api_client/api/workoutsession/workoutsession_list.py b/wger_api_client/api/workoutsession/workoutsession_list.py index 94f0a1b..2c5c286 100644 --- a/wger_api_client/api/workoutsession/workoutsession_list.py +++ b/wger_api_client/api/workoutsession/workoutsession_list.py @@ -15,23 +15,90 @@ def _get_kwargs( *, - date: datetime.date | Unset = UNSET, + datetime_end: datetime.datetime | Unset = UNSET, + datetime_end_date: datetime.date | Unset = UNSET, + datetime_end_gt: datetime.datetime | Unset = UNSET, + datetime_end_gte: datetime.datetime | Unset = UNSET, + datetime_end_lt: datetime.datetime | Unset = UNSET, + datetime_end_lte: datetime.datetime | Unset = UNSET, + datetime_start: datetime.datetime | Unset = UNSET, + datetime_start_date: datetime.date | Unset = UNSET, + datetime_start_gt: datetime.datetime | Unset = UNSET, + datetime_start_gte: datetime.datetime | Unset = UNSET, + datetime_start_lt: datetime.datetime | Unset = UNSET, + datetime_start_lte: datetime.datetime | Unset = UNSET, + day: int | Unset = UNSET, impression: WorkoutsessionListGeneralImpression | Unset = UNSET, limit: int | Unset = UNSET, notes: str | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, routine: int | Unset = UNSET, - time_end: str | Unset = UNSET, - time_start: str | Unset = UNSET, ) -> dict[str, Any]: params: dict[str, Any] = {} - json_date: str | Unset = UNSET - if not isinstance(date, Unset): - json_date = date.isoformat() - params["date"] = json_date + json_datetime_end: str | Unset = UNSET + if not isinstance(datetime_end, Unset): + json_datetime_end = datetime_end.isoformat() + params["datetime_end"] = json_datetime_end + + json_datetime_end_date: str | Unset = UNSET + if not isinstance(datetime_end_date, Unset): + json_datetime_end_date = datetime_end_date.isoformat() + params["datetime_end__date"] = json_datetime_end_date + + json_datetime_end_gt: str | Unset = UNSET + if not isinstance(datetime_end_gt, Unset): + json_datetime_end_gt = datetime_end_gt.isoformat() + params["datetime_end__gt"] = json_datetime_end_gt + + json_datetime_end_gte: str | Unset = UNSET + if not isinstance(datetime_end_gte, Unset): + json_datetime_end_gte = datetime_end_gte.isoformat() + params["datetime_end__gte"] = json_datetime_end_gte + + json_datetime_end_lt: str | Unset = UNSET + if not isinstance(datetime_end_lt, Unset): + json_datetime_end_lt = datetime_end_lt.isoformat() + params["datetime_end__lt"] = json_datetime_end_lt + + json_datetime_end_lte: str | Unset = UNSET + if not isinstance(datetime_end_lte, Unset): + json_datetime_end_lte = datetime_end_lte.isoformat() + params["datetime_end__lte"] = json_datetime_end_lte + + json_datetime_start: str | Unset = UNSET + if not isinstance(datetime_start, Unset): + json_datetime_start = datetime_start.isoformat() + params["datetime_start"] = json_datetime_start + + json_datetime_start_date: str | Unset = UNSET + if not isinstance(datetime_start_date, Unset): + json_datetime_start_date = datetime_start_date.isoformat() + params["datetime_start__date"] = json_datetime_start_date + + json_datetime_start_gt: str | Unset = UNSET + if not isinstance(datetime_start_gt, Unset): + json_datetime_start_gt = datetime_start_gt.isoformat() + params["datetime_start__gt"] = json_datetime_start_gt + + json_datetime_start_gte: str | Unset = UNSET + if not isinstance(datetime_start_gte, Unset): + json_datetime_start_gte = datetime_start_gte.isoformat() + params["datetime_start__gte"] = json_datetime_start_gte + + json_datetime_start_lt: str | Unset = UNSET + if not isinstance(datetime_start_lt, Unset): + json_datetime_start_lt = datetime_start_lt.isoformat() + params["datetime_start__lt"] = json_datetime_start_lt + + json_datetime_start_lte: str | Unset = UNSET + if not isinstance(datetime_start_lte, Unset): + json_datetime_start_lte = datetime_start_lte.isoformat() + params["datetime_start__lte"] = json_datetime_start_lte + + params["day"] = day json_impression: str | Unset = UNSET if not isinstance(impression, Unset): @@ -49,10 +116,6 @@ def _get_kwargs( params["routine"] = routine - params["time_end"] = time_end - - params["time_start"] = time_start - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} _kwargs: dict[str, Any] = { @@ -92,28 +155,48 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient, - date: datetime.date | Unset = UNSET, + datetime_end: datetime.datetime | Unset = UNSET, + datetime_end_date: datetime.date | Unset = UNSET, + datetime_end_gt: datetime.datetime | Unset = UNSET, + datetime_end_gte: datetime.datetime | Unset = UNSET, + datetime_end_lt: datetime.datetime | Unset = UNSET, + datetime_end_lte: datetime.datetime | Unset = UNSET, + datetime_start: datetime.datetime | Unset = UNSET, + datetime_start_date: datetime.date | Unset = UNSET, + datetime_start_gt: datetime.datetime | Unset = UNSET, + datetime_start_gte: datetime.datetime | Unset = UNSET, + datetime_start_lt: datetime.datetime | Unset = UNSET, + datetime_start_lte: datetime.datetime | Unset = UNSET, + day: int | Unset = UNSET, impression: WorkoutsessionListGeneralImpression | Unset = UNSET, limit: int | Unset = UNSET, notes: str | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, routine: int | Unset = UNSET, - time_end: str | Unset = UNSET, - time_start: str | Unset = UNSET, ) -> Response[PaginatedWorkoutSessionList]: """API endpoint for workout sessions objects Args: - date (datetime.date | Unset): + datetime_end (datetime.datetime | Unset): + datetime_end_date (datetime.date | Unset): + datetime_end_gt (datetime.datetime | Unset): + datetime_end_gte (datetime.datetime | Unset): + datetime_end_lt (datetime.datetime | Unset): + datetime_end_lte (datetime.datetime | Unset): + datetime_start (datetime.datetime | Unset): + datetime_start_date (datetime.date | Unset): + datetime_start_gt (datetime.datetime | Unset): + datetime_start_gte (datetime.datetime | Unset): + datetime_start_lt (datetime.datetime | Unset): + datetime_start_lte (datetime.datetime | Unset): + day (int | Unset): impression (WorkoutsessionListGeneralImpression | Unset): limit (int | Unset): notes (str | Unset): offset (int | Unset): ordering (str | Unset): routine (int | Unset): - time_end (str | Unset): - time_start (str | Unset): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -124,15 +207,25 @@ def sync_detailed( """ kwargs = _get_kwargs( - date=date, + datetime_end=datetime_end, + datetime_end_date=datetime_end_date, + datetime_end_gt=datetime_end_gt, + datetime_end_gte=datetime_end_gte, + datetime_end_lt=datetime_end_lt, + datetime_end_lte=datetime_end_lte, + datetime_start=datetime_start, + datetime_start_date=datetime_start_date, + datetime_start_gt=datetime_start_gt, + datetime_start_gte=datetime_start_gte, + datetime_start_lt=datetime_start_lt, + datetime_start_lte=datetime_start_lte, + day=day, impression=impression, limit=limit, notes=notes, offset=offset, ordering=ordering, routine=routine, - time_end=time_end, - time_start=time_start, ) response = client.get_httpx_client().request( @@ -145,28 +238,48 @@ def sync_detailed( def sync( *, client: AuthenticatedClient, - date: datetime.date | Unset = UNSET, + datetime_end: datetime.datetime | Unset = UNSET, + datetime_end_date: datetime.date | Unset = UNSET, + datetime_end_gt: datetime.datetime | Unset = UNSET, + datetime_end_gte: datetime.datetime | Unset = UNSET, + datetime_end_lt: datetime.datetime | Unset = UNSET, + datetime_end_lte: datetime.datetime | Unset = UNSET, + datetime_start: datetime.datetime | Unset = UNSET, + datetime_start_date: datetime.date | Unset = UNSET, + datetime_start_gt: datetime.datetime | Unset = UNSET, + datetime_start_gte: datetime.datetime | Unset = UNSET, + datetime_start_lt: datetime.datetime | Unset = UNSET, + datetime_start_lte: datetime.datetime | Unset = UNSET, + day: int | Unset = UNSET, impression: WorkoutsessionListGeneralImpression | Unset = UNSET, limit: int | Unset = UNSET, notes: str | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, routine: int | Unset = UNSET, - time_end: str | Unset = UNSET, - time_start: str | Unset = UNSET, ) -> PaginatedWorkoutSessionList | None: """API endpoint for workout sessions objects Args: - date (datetime.date | Unset): + datetime_end (datetime.datetime | Unset): + datetime_end_date (datetime.date | Unset): + datetime_end_gt (datetime.datetime | Unset): + datetime_end_gte (datetime.datetime | Unset): + datetime_end_lt (datetime.datetime | Unset): + datetime_end_lte (datetime.datetime | Unset): + datetime_start (datetime.datetime | Unset): + datetime_start_date (datetime.date | Unset): + datetime_start_gt (datetime.datetime | Unset): + datetime_start_gte (datetime.datetime | Unset): + datetime_start_lt (datetime.datetime | Unset): + datetime_start_lte (datetime.datetime | Unset): + day (int | Unset): impression (WorkoutsessionListGeneralImpression | Unset): limit (int | Unset): notes (str | Unset): offset (int | Unset): ordering (str | Unset): routine (int | Unset): - time_end (str | Unset): - time_start (str | Unset): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -178,43 +291,73 @@ def sync( return sync_detailed( client=client, - date=date, + datetime_end=datetime_end, + datetime_end_date=datetime_end_date, + datetime_end_gt=datetime_end_gt, + datetime_end_gte=datetime_end_gte, + datetime_end_lt=datetime_end_lt, + datetime_end_lte=datetime_end_lte, + datetime_start=datetime_start, + datetime_start_date=datetime_start_date, + datetime_start_gt=datetime_start_gt, + datetime_start_gte=datetime_start_gte, + datetime_start_lt=datetime_start_lt, + datetime_start_lte=datetime_start_lte, + day=day, impression=impression, limit=limit, notes=notes, offset=offset, ordering=ordering, routine=routine, - time_end=time_end, - time_start=time_start, ).parsed async def asyncio_detailed( *, client: AuthenticatedClient, - date: datetime.date | Unset = UNSET, + datetime_end: datetime.datetime | Unset = UNSET, + datetime_end_date: datetime.date | Unset = UNSET, + datetime_end_gt: datetime.datetime | Unset = UNSET, + datetime_end_gte: datetime.datetime | Unset = UNSET, + datetime_end_lt: datetime.datetime | Unset = UNSET, + datetime_end_lte: datetime.datetime | Unset = UNSET, + datetime_start: datetime.datetime | Unset = UNSET, + datetime_start_date: datetime.date | Unset = UNSET, + datetime_start_gt: datetime.datetime | Unset = UNSET, + datetime_start_gte: datetime.datetime | Unset = UNSET, + datetime_start_lt: datetime.datetime | Unset = UNSET, + datetime_start_lte: datetime.datetime | Unset = UNSET, + day: int | Unset = UNSET, impression: WorkoutsessionListGeneralImpression | Unset = UNSET, limit: int | Unset = UNSET, notes: str | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, routine: int | Unset = UNSET, - time_end: str | Unset = UNSET, - time_start: str | Unset = UNSET, ) -> Response[PaginatedWorkoutSessionList]: """API endpoint for workout sessions objects Args: - date (datetime.date | Unset): + datetime_end (datetime.datetime | Unset): + datetime_end_date (datetime.date | Unset): + datetime_end_gt (datetime.datetime | Unset): + datetime_end_gte (datetime.datetime | Unset): + datetime_end_lt (datetime.datetime | Unset): + datetime_end_lte (datetime.datetime | Unset): + datetime_start (datetime.datetime | Unset): + datetime_start_date (datetime.date | Unset): + datetime_start_gt (datetime.datetime | Unset): + datetime_start_gte (datetime.datetime | Unset): + datetime_start_lt (datetime.datetime | Unset): + datetime_start_lte (datetime.datetime | Unset): + day (int | Unset): impression (WorkoutsessionListGeneralImpression | Unset): limit (int | Unset): notes (str | Unset): offset (int | Unset): ordering (str | Unset): routine (int | Unset): - time_end (str | Unset): - time_start (str | Unset): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -225,15 +368,25 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( - date=date, + datetime_end=datetime_end, + datetime_end_date=datetime_end_date, + datetime_end_gt=datetime_end_gt, + datetime_end_gte=datetime_end_gte, + datetime_end_lt=datetime_end_lt, + datetime_end_lte=datetime_end_lte, + datetime_start=datetime_start, + datetime_start_date=datetime_start_date, + datetime_start_gt=datetime_start_gt, + datetime_start_gte=datetime_start_gte, + datetime_start_lt=datetime_start_lt, + datetime_start_lte=datetime_start_lte, + day=day, impression=impression, limit=limit, notes=notes, offset=offset, ordering=ordering, routine=routine, - time_end=time_end, - time_start=time_start, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -244,28 +397,48 @@ async def asyncio_detailed( async def asyncio( *, client: AuthenticatedClient, - date: datetime.date | Unset = UNSET, + datetime_end: datetime.datetime | Unset = UNSET, + datetime_end_date: datetime.date | Unset = UNSET, + datetime_end_gt: datetime.datetime | Unset = UNSET, + datetime_end_gte: datetime.datetime | Unset = UNSET, + datetime_end_lt: datetime.datetime | Unset = UNSET, + datetime_end_lte: datetime.datetime | Unset = UNSET, + datetime_start: datetime.datetime | Unset = UNSET, + datetime_start_date: datetime.date | Unset = UNSET, + datetime_start_gt: datetime.datetime | Unset = UNSET, + datetime_start_gte: datetime.datetime | Unset = UNSET, + datetime_start_lt: datetime.datetime | Unset = UNSET, + datetime_start_lte: datetime.datetime | Unset = UNSET, + day: int | Unset = UNSET, impression: WorkoutsessionListGeneralImpression | Unset = UNSET, limit: int | Unset = UNSET, notes: str | Unset = UNSET, offset: int | Unset = UNSET, ordering: str | Unset = UNSET, routine: int | Unset = UNSET, - time_end: str | Unset = UNSET, - time_start: str | Unset = UNSET, ) -> PaginatedWorkoutSessionList | None: """API endpoint for workout sessions objects Args: - date (datetime.date | Unset): + datetime_end (datetime.datetime | Unset): + datetime_end_date (datetime.date | Unset): + datetime_end_gt (datetime.datetime | Unset): + datetime_end_gte (datetime.datetime | Unset): + datetime_end_lt (datetime.datetime | Unset): + datetime_end_lte (datetime.datetime | Unset): + datetime_start (datetime.datetime | Unset): + datetime_start_date (datetime.date | Unset): + datetime_start_gt (datetime.datetime | Unset): + datetime_start_gte (datetime.datetime | Unset): + datetime_start_lt (datetime.datetime | Unset): + datetime_start_lte (datetime.datetime | Unset): + day (int | Unset): impression (WorkoutsessionListGeneralImpression | Unset): limit (int | Unset): notes (str | Unset): offset (int | Unset): ordering (str | Unset): routine (int | Unset): - time_end (str | Unset): - time_start (str | Unset): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -278,14 +451,24 @@ async def asyncio( return ( await asyncio_detailed( client=client, - date=date, + datetime_end=datetime_end, + datetime_end_date=datetime_end_date, + datetime_end_gt=datetime_end_gt, + datetime_end_gte=datetime_end_gte, + datetime_end_lt=datetime_end_lt, + datetime_end_lte=datetime_end_lte, + datetime_start=datetime_start, + datetime_start_date=datetime_start_date, + datetime_start_gt=datetime_start_gt, + datetime_start_gte=datetime_start_gte, + datetime_start_lt=datetime_start_lt, + datetime_start_lte=datetime_start_lte, + day=day, impression=impression, limit=limit, notes=notes, offset=offset, ordering=ordering, routine=routine, - time_end=time_end, - time_start=time_start, ) ).parsed diff --git a/wger_api_client/models/__init__.py b/wger_api_client/models/__init__.py index f8610a6..bd73a8d 100644 --- a/wger_api_client/models/__init__.py +++ b/wger_api_client/models/__init__.py @@ -1,8 +1,10 @@ """Contains all the data models used in inputs/outputs""" from .blank_enum import BlankEnum +from .bucket import Bucket from .category import Category from .category_request import CategoryRequest +from .chart_type_enum import ChartTypeEnum from .cursor_paginated_ingredient_info_list import CursorPaginatedIngredientInfoList from .day import Day from .day_request import DayRequest @@ -10,6 +12,8 @@ from .day_type_enum import DayTypeEnum from .deletion_log import DeletionLog from .deletion_log_list_model_type import DeletionLogListModelType +from .dynamic_type import DynamicType +from .dynamic_type_enum import DynamicTypeEnum from .equipment import Equipment from .exercise import Exercise from .exercise_alias import ExerciseAlias @@ -96,7 +100,13 @@ from .meal_item_request import MealItemRequest from .meal_request import MealRequest from .measurement import Measurement +from .measurement_aggregate_list_bucket import MeasurementAggregateListBucket +from .measurement_aggregate_list_source import MeasurementAggregateListSource +from .measurement_category_list_metric_type import MeasurementCategoryListMetricType +from .measurement_list_source import MeasurementListSource from .measurement_request import MeasurementRequest +from .measurement_value_counts_list_source import MeasurementValueCountsListSource +from .metric_type_enum import MetricTypeEnum from .model_type_enum import ModelTypeEnum from .muscle import Muscle from .nutriscore_enum import NutriscoreEnum @@ -190,7 +200,6 @@ from .powersync_token_response import PowersyncTokenResponse from .powersync_upload_request import PowersyncUploadRequest from .powersync_upload_response import PowersyncUploadResponse -from .refresh_token_response import RefreshTokenResponse from .repetition_unit import RepetitionUnit from .repetitions_config import RepetitionsConfig from .repetitions_config_list_operation import RepetitionsConfigListOperation @@ -224,6 +233,7 @@ from .slot_entry_structure import SlotEntryStructure from .slot_request import SlotRequest from .slot_structure import SlotStructure +from .source_enum import SourceEnum from .step_enum import StepEnum from .style_enum import StyleEnum from .thumbnail_alias import ThumbnailAlias @@ -243,6 +253,7 @@ from .user_trophy_list_trophy_trophy_type import UserTrophyListTrophyTrophyType from .userprofile import Userprofile from .userprofile_request import UserprofileRequest +from .value_count import ValueCount from .verify_email_response import VerifyEmailResponse from .weight_config import WeightConfig from .weight_config_list_operation import WeightConfigListOperation @@ -261,8 +272,10 @@ __all__ = ( "BlankEnum", + "Bucket", "Category", "CategoryRequest", + "ChartTypeEnum", "CursorPaginatedIngredientInfoList", "Day", "DayRequest", @@ -270,6 +283,8 @@ "DayTypeEnum", "DeletionLog", "DeletionLogListModelType", + "DynamicType", + "DynamicTypeEnum", "Equipment", "Exercise", "ExerciseAlias", @@ -354,7 +369,13 @@ "MealItemRequest", "MealRequest", "Measurement", + "MeasurementAggregateListBucket", + "MeasurementAggregateListSource", + "MeasurementCategoryListMetricType", + "MeasurementListSource", "MeasurementRequest", + "MeasurementValueCountsListSource", + "MetricTypeEnum", "ModelTypeEnum", "Muscle", "NutriscoreEnum", @@ -448,7 +469,6 @@ "PowersyncTokenResponse", "PowersyncUploadRequest", "PowersyncUploadResponse", - "RefreshTokenResponse", "RepetitionUnit", "RepetitionsConfig", "RepetitionsConfigListOperation", @@ -482,6 +502,7 @@ "SlotEntryStructure", "SlotRequest", "SlotStructure", + "SourceEnum", "StepEnum", "StyleEnum", "ThumbnailAlias", @@ -501,6 +522,7 @@ "UserTrophyListTrophyTrophyType", "Userprofile", "UserprofileRequest", + "ValueCount", "VerifyEmailResponse", "WeightConfig", "WeightConfigListOperation", diff --git a/wger_api_client/models/bucket.py b/wger_api_client/models/bucket.py new file mode 100644 index 0000000..a531fcf --- /dev/null +++ b/wger_api_client/models/bucket.py @@ -0,0 +1,120 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import Any, Self, TypeVar, cast +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="Bucket") + + +@_attrs_define +class Bucket: + """One calendar bucket of a category's entries, see `api.aggregates`. + + Read-only: buckets are derived, there is nothing to write back. + + Attributes: + category (UUID): + start (datetime.datetime): + unit (None | str): + count (int): + sum_ (str): + min_ (str): + max_ (str): + """ + + category: UUID + start: datetime.datetime + unit: None | str + count: int + sum_: str + min_: str + max_: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + category = str(self.category) + + start = self.start.isoformat() + + unit: None | str + unit = self.unit + + count = self.count + + sum_ = self.sum_ + + min_ = self.min_ + + max_ = self.max_ + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "category": category, + "start": start, + "unit": unit, + "count": count, + "sum": sum_, + "min": min_, + "max": max_, + } + ) + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + d = dict(src_dict) + category = UUID(d.pop("category")) + + start = datetime.datetime.fromisoformat(d.pop("start")) + + def _parse_unit(data: object) -> None | str: + if data is None: + return data + return cast(None | str, data) + + unit = _parse_unit(d.pop("unit")) + + count = d.pop("count") + + sum_ = d.pop("sum") + + min_ = d.pop("min") + + max_ = d.pop("max") + + bucket = cls( + category=category, + start=start, + unit=unit, + count=count, + sum_=sum_, + min_=min_, + max_=max_, + ) + + bucket.additional_properties = d + return bucket + + @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 diff --git a/wger_api_client/models/category.py b/wger_api_client/models/category.py index f1b45de..c5d9457 100644 --- a/wger_api_client/models/category.py +++ b/wger_api_client/models/category.py @@ -1,12 +1,16 @@ from __future__ import annotations from collections.abc import Mapping -from typing import Any, Self, TypeVar +from typing import Any, Self, TypeVar, cast from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field +from ..models.blank_enum import BlankEnum, check_blank_enum +from ..models.chart_type_enum import ChartTypeEnum, check_chart_type_enum +from ..models.dynamic_type_enum import DynamicTypeEnum, check_dynamic_type_enum +from ..models.metric_type_enum import MetricTypeEnum, check_metric_type_enum from ..types import UNSET, Unset T = TypeVar("T", bound="Category") @@ -18,34 +22,121 @@ class Category: Attributes: name (str): - unit (str): + is_official (bool): id (UUID | Unset): + unit (str | Unset): + metric_type (MetricTypeEnum | Unset): * `custom` - Custom + * `body_weight` - Body Weight + * `body_fat` - Body Fat + * `lean_body_mass` - Lean Body Mass + * `height` - Height + * `blood_pressure` - Blood Pressure + * `blood_pressure_systolic` - Blood Pressure Systolic + * `blood_pressure_diastolic` - Blood Pressure Diastolic + * `heart_rate` - Heart Rate + * `resting_heart_rate` - Resting Heart Rate + * `blood_oxygen` - Blood Oxygen + * `steps` - Steps + * `distance` - Distance + * `energy` - Energy + * `sleep` - Sleep + * `sleep_total` - Total sleep + * `sleep_light` - Light sleep + * `sleep_deep` - Deep sleep + * `sleep_rem` - REM sleep + * `sleep_awake` - Awake + chart_type (BlankEnum | ChartTypeEnum | None | Unset): + chart_config (Any | Unset): + parent (None | Unset | UUID): + order (int | Unset): + dynamic_type (DynamicTypeEnum | Unset): * `NONE` - None + * `BMI` - BMI + * `WHTR` - Waist-to-height ratio + * `ONE_REP_MAX` - 1RM + * `ONE_RM_TOTAL` - 1RM total + dynamic_params (Any | Unset): Configuration parameters for dynamic calculations """ name: str - unit: str + is_official: bool id: UUID | Unset = UNSET + unit: str | Unset = UNSET + metric_type: MetricTypeEnum | Unset = UNSET + chart_type: BlankEnum | ChartTypeEnum | None | Unset = UNSET + chart_config: Any | Unset = UNSET + parent: None | Unset | UUID = UNSET + order: int | Unset = UNSET + dynamic_type: DynamicTypeEnum | Unset = UNSET + dynamic_params: Any | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: name = self.name - unit = self.unit + is_official = self.is_official id: str | Unset = UNSET if not isinstance(self.id, Unset): id = str(self.id) + unit = self.unit + + metric_type: str | Unset = UNSET + if not isinstance(self.metric_type, Unset): + metric_type = self.metric_type + + chart_type: None | str | Unset + if isinstance(self.chart_type, Unset): + chart_type = UNSET + elif isinstance(self.chart_type, str) or isinstance(self.chart_type, str): + chart_type = self.chart_type + else: + chart_type = self.chart_type + + chart_config = self.chart_config + + parent: None | str | Unset + if isinstance(self.parent, Unset): + parent = UNSET + elif isinstance(self.parent, UUID): + parent = str(self.parent) + else: + parent = self.parent + + order = self.order + + dynamic_type: str | Unset = UNSET + if not isinstance(self.dynamic_type, Unset): + dynamic_type = self.dynamic_type + + dynamic_params = self.dynamic_params + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { "name": name, - "unit": unit, + "is_official": is_official, } ) if id is not UNSET: field_dict["id"] = id + if unit is not UNSET: + field_dict["unit"] = unit + if metric_type is not UNSET: + field_dict["metric_type"] = metric_type + if chart_type is not UNSET: + field_dict["chart_type"] = chart_type + if chart_config is not UNSET: + field_dict["chart_config"] = chart_config + if parent is not UNSET: + field_dict["parent"] = parent + if order is not UNSET: + field_dict["order"] = order + if dynamic_type is not UNSET: + field_dict["dynamic_type"] = dynamic_type + if dynamic_params is not UNSET: + field_dict["dynamic_params"] = dynamic_params return field_dict @@ -54,7 +145,7 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: d = dict(src_dict) name = d.pop("name") - unit = d.pop("unit") + is_official = d.pop("is_official") _id = d.pop("id", UNSET) id: UUID | Unset @@ -63,10 +154,82 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: else: id = UUID(_id) + unit = d.pop("unit", UNSET) + + _metric_type = d.pop("metric_type", UNSET) + metric_type: MetricTypeEnum | Unset + if isinstance(_metric_type, Unset): + metric_type = UNSET + else: + metric_type = check_metric_type_enum(_metric_type) + + def _parse_chart_type(data: object) -> BlankEnum | ChartTypeEnum | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + chart_type_type_0 = check_chart_type_enum(data) + + return chart_type_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + try: + if not isinstance(data, str): + raise TypeError() + chart_type_type_1 = check_blank_enum(data) + + return chart_type_type_1 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(BlankEnum | ChartTypeEnum | None | Unset, data) + + chart_type = _parse_chart_type(d.pop("chart_type", UNSET)) + + chart_config = d.pop("chart_config", UNSET) + + def _parse_parent(data: object) -> None | Unset | UUID: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + parent_type_0 = UUID(data) + + return parent_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | UUID, data) + + parent = _parse_parent(d.pop("parent", UNSET)) + + order = d.pop("order", UNSET) + + _dynamic_type = d.pop("dynamic_type", UNSET) + dynamic_type: DynamicTypeEnum | Unset + if isinstance(_dynamic_type, Unset): + dynamic_type = UNSET + else: + dynamic_type = check_dynamic_type_enum(_dynamic_type) + + dynamic_params = d.pop("dynamic_params", UNSET) + category = cls( name=name, - unit=unit, + is_official=is_official, id=id, + unit=unit, + metric_type=metric_type, + chart_type=chart_type, + chart_config=chart_config, + parent=parent, + order=order, + dynamic_type=dynamic_type, + dynamic_params=dynamic_params, ) category.additional_properties = d diff --git a/wger_api_client/models/category_request.py b/wger_api_client/models/category_request.py index 71e1979..73d44bb 100644 --- a/wger_api_client/models/category_request.py +++ b/wger_api_client/models/category_request.py @@ -1,12 +1,16 @@ from __future__ import annotations from collections.abc import Mapping -from typing import Any, Self, TypeVar +from typing import Any, Self, TypeVar, cast from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field +from ..models.blank_enum import BlankEnum, check_blank_enum +from ..models.chart_type_enum import ChartTypeEnum, check_chart_type_enum +from ..models.dynamic_type_enum import DynamicTypeEnum, check_dynamic_type_enum +from ..models.metric_type_enum import MetricTypeEnum, check_metric_type_enum from ..types import UNSET, Unset T = TypeVar("T", bound="CategoryRequest") @@ -18,34 +22,116 @@ class CategoryRequest: Attributes: name (str): - unit (str): id (UUID | Unset): + unit (str | Unset): + metric_type (MetricTypeEnum | Unset): * `custom` - Custom + * `body_weight` - Body Weight + * `body_fat` - Body Fat + * `lean_body_mass` - Lean Body Mass + * `height` - Height + * `blood_pressure` - Blood Pressure + * `blood_pressure_systolic` - Blood Pressure Systolic + * `blood_pressure_diastolic` - Blood Pressure Diastolic + * `heart_rate` - Heart Rate + * `resting_heart_rate` - Resting Heart Rate + * `blood_oxygen` - Blood Oxygen + * `steps` - Steps + * `distance` - Distance + * `energy` - Energy + * `sleep` - Sleep + * `sleep_total` - Total sleep + * `sleep_light` - Light sleep + * `sleep_deep` - Deep sleep + * `sleep_rem` - REM sleep + * `sleep_awake` - Awake + chart_type (BlankEnum | ChartTypeEnum | None | Unset): + chart_config (Any | Unset): + parent (None | Unset | UUID): + order (int | Unset): + dynamic_type (DynamicTypeEnum | Unset): * `NONE` - None + * `BMI` - BMI + * `WHTR` - Waist-to-height ratio + * `ONE_REP_MAX` - 1RM + * `ONE_RM_TOTAL` - 1RM total + dynamic_params (Any | Unset): Configuration parameters for dynamic calculations """ name: str - unit: str id: UUID | Unset = UNSET + unit: str | Unset = UNSET + metric_type: MetricTypeEnum | Unset = UNSET + chart_type: BlankEnum | ChartTypeEnum | None | Unset = UNSET + chart_config: Any | Unset = UNSET + parent: None | Unset | UUID = UNSET + order: int | Unset = UNSET + dynamic_type: DynamicTypeEnum | Unset = UNSET + dynamic_params: Any | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: name = self.name - unit = self.unit - id: str | Unset = UNSET if not isinstance(self.id, Unset): id = str(self.id) + unit = self.unit + + metric_type: str | Unset = UNSET + if not isinstance(self.metric_type, Unset): + metric_type = self.metric_type + + chart_type: None | str | Unset + if isinstance(self.chart_type, Unset): + chart_type = UNSET + elif isinstance(self.chart_type, str) or isinstance(self.chart_type, str): + chart_type = self.chart_type + else: + chart_type = self.chart_type + + chart_config = self.chart_config + + parent: None | str | Unset + if isinstance(self.parent, Unset): + parent = UNSET + elif isinstance(self.parent, UUID): + parent = str(self.parent) + else: + parent = self.parent + + order = self.order + + dynamic_type: str | Unset = UNSET + if not isinstance(self.dynamic_type, Unset): + dynamic_type = self.dynamic_type + + dynamic_params = self.dynamic_params + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { "name": name, - "unit": unit, } ) if id is not UNSET: field_dict["id"] = id + if unit is not UNSET: + field_dict["unit"] = unit + if metric_type is not UNSET: + field_dict["metric_type"] = metric_type + if chart_type is not UNSET: + field_dict["chart_type"] = chart_type + if chart_config is not UNSET: + field_dict["chart_config"] = chart_config + if parent is not UNSET: + field_dict["parent"] = parent + if order is not UNSET: + field_dict["order"] = order + if dynamic_type is not UNSET: + field_dict["dynamic_type"] = dynamic_type + if dynamic_params is not UNSET: + field_dict["dynamic_params"] = dynamic_params return field_dict @@ -54,8 +140,6 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: d = dict(src_dict) name = d.pop("name") - unit = d.pop("unit") - _id = d.pop("id", UNSET) id: UUID | Unset if isinstance(_id, Unset): @@ -63,10 +147,81 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: else: id = UUID(_id) + unit = d.pop("unit", UNSET) + + _metric_type = d.pop("metric_type", UNSET) + metric_type: MetricTypeEnum | Unset + if isinstance(_metric_type, Unset): + metric_type = UNSET + else: + metric_type = check_metric_type_enum(_metric_type) + + def _parse_chart_type(data: object) -> BlankEnum | ChartTypeEnum | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + chart_type_type_0 = check_chart_type_enum(data) + + return chart_type_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + try: + if not isinstance(data, str): + raise TypeError() + chart_type_type_1 = check_blank_enum(data) + + return chart_type_type_1 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(BlankEnum | ChartTypeEnum | None | Unset, data) + + chart_type = _parse_chart_type(d.pop("chart_type", UNSET)) + + chart_config = d.pop("chart_config", UNSET) + + def _parse_parent(data: object) -> None | Unset | UUID: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + parent_type_0 = UUID(data) + + return parent_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | UUID, data) + + parent = _parse_parent(d.pop("parent", UNSET)) + + order = d.pop("order", UNSET) + + _dynamic_type = d.pop("dynamic_type", UNSET) + dynamic_type: DynamicTypeEnum | Unset + if isinstance(_dynamic_type, Unset): + dynamic_type = UNSET + else: + dynamic_type = check_dynamic_type_enum(_dynamic_type) + + dynamic_params = d.pop("dynamic_params", UNSET) + category_request = cls( name=name, - unit=unit, id=id, + unit=unit, + metric_type=metric_type, + chart_type=chart_type, + chart_config=chart_config, + parent=parent, + order=order, + dynamic_type=dynamic_type, + dynamic_params=dynamic_params, ) category_request.additional_properties = d diff --git a/wger_api_client/models/chart_type_enum.py b/wger_api_client/models/chart_type_enum.py new file mode 100644 index 0000000..79cdbd6 --- /dev/null +++ b/wger_api_client/models/chart_type_enum.py @@ -0,0 +1,19 @@ +from typing import Literal + +ChartTypeEnum = Literal["bar", "delta", "distribution", "heatmap", "line"] + +CHART_TYPE_ENUM_VALUES: set[ChartTypeEnum] = { + "bar", + "delta", + "distribution", + "heatmap", + "line", +} + + +def check_chart_type_enum(value: str) -> ChartTypeEnum: + if value in CHART_TYPE_ENUM_VALUES: + return value + raise TypeError( + f"Unexpected value {value!r}. Expected one of {CHART_TYPE_ENUM_VALUES!r}" + ) diff --git a/wger_api_client/models/refresh_token_response.py b/wger_api_client/models/dynamic_type.py similarity index 57% rename from wger_api_client/models/refresh_token_response.py rename to wger_api_client/models/dynamic_type.py index 736afbb..ec0b619 100644 --- a/wger_api_client/models/refresh_token_response.py +++ b/wger_api_client/models/dynamic_type.py @@ -6,27 +6,39 @@ from attrs import define as _attrs_define from attrs import field as _attrs_field -T = TypeVar("T", bound="RefreshTokenResponse") +T = TypeVar("T", bound="DynamicType") @_attrs_define -class RefreshTokenResponse: - """ - Attributes: - refresh_token (str): +class DynamicType: + """One calculated category type of the registry. Read-only: the registry is + code, there is nothing to write back. + + Attributes: + value (str): + label (str): + params_schema (Any): """ - refresh_token: str + value: str + label: str + params_schema: Any additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - refresh_token = self.refresh_token + value = self.value + + label = self.label + + params_schema = self.params_schema field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { - "refresh_token": refresh_token, + "value": value, + "label": label, + "params_schema": params_schema, } ) @@ -35,14 +47,20 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: d = dict(src_dict) - refresh_token = d.pop("refresh_token") + value = d.pop("value") + + label = d.pop("label") + + params_schema = d.pop("params_schema") - refresh_token_response = cls( - refresh_token=refresh_token, + dynamic_type = cls( + value=value, + label=label, + params_schema=params_schema, ) - refresh_token_response.additional_properties = d - return refresh_token_response + dynamic_type.additional_properties = d + return dynamic_type @property def additional_keys(self) -> list[str]: diff --git a/wger_api_client/models/dynamic_type_enum.py b/wger_api_client/models/dynamic_type_enum.py new file mode 100644 index 0000000..4b2881f --- /dev/null +++ b/wger_api_client/models/dynamic_type_enum.py @@ -0,0 +1,19 @@ +from typing import Literal + +DynamicTypeEnum = Literal["BMI", "NONE", "ONE_REP_MAX", "ONE_RM_TOTAL", "WHTR"] + +DYNAMIC_TYPE_ENUM_VALUES: set[DynamicTypeEnum] = { + "BMI", + "NONE", + "ONE_REP_MAX", + "ONE_RM_TOTAL", + "WHTR", +} + + +def check_dynamic_type_enum(value: str) -> DynamicTypeEnum: + if value in DYNAMIC_TYPE_ENUM_VALUES: + return value + raise TypeError( + f"Unexpected value {value!r}. Expected one of {DYNAMIC_TYPE_ENUM_VALUES!r}" + ) diff --git a/wger_api_client/models/measurement.py b/wger_api_client/models/measurement.py index 161b6f9..c4739d8 100644 --- a/wger_api_client/models/measurement.py +++ b/wger_api_client/models/measurement.py @@ -2,12 +2,13 @@ import datetime from collections.abc import Mapping -from typing import Any, Self, TypeVar +from typing import Any, Self, TypeVar, cast from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field +from ..models.source_enum import SourceEnum, check_source_enum from ..types import UNSET, Unset T = TypeVar("T", bound="Measurement") @@ -23,6 +24,12 @@ class Measurement: id (UUID | Unset): date (datetime.datetime | Unset): notes (str | Unset): + source (SourceEnum | Unset): * `user` - User + * `google` - Google + * `apple` - Apple + * `calculated` - Calculated Default: 'user'. + external_id (None | Unset | UUID): + extra_data (Any | Unset): """ category: UUID @@ -30,6 +37,9 @@ class Measurement: id: UUID | Unset = UNSET date: datetime.datetime | Unset = UNSET notes: str | Unset = UNSET + source: SourceEnum | Unset = "user" + external_id: None | Unset | UUID = UNSET + extra_data: Any | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -47,6 +57,20 @@ def to_dict(self) -> dict[str, Any]: notes = self.notes + source: str | Unset = UNSET + if not isinstance(self.source, Unset): + source = self.source + + external_id: None | str | Unset + if isinstance(self.external_id, Unset): + external_id = UNSET + elif isinstance(self.external_id, UUID): + external_id = str(self.external_id) + else: + external_id = self.external_id + + extra_data = self.extra_data + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( @@ -61,6 +85,12 @@ def to_dict(self) -> dict[str, Any]: field_dict["date"] = date if notes is not UNSET: field_dict["notes"] = notes + if source is not UNSET: + field_dict["source"] = source + if external_id is not UNSET: + field_dict["external_id"] = external_id + if extra_data is not UNSET: + field_dict["extra_data"] = extra_data return field_dict @@ -87,12 +117,41 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: notes = d.pop("notes", UNSET) + _source = d.pop("source", UNSET) + source: SourceEnum | Unset + if isinstance(_source, Unset): + source = UNSET + else: + source = check_source_enum(_source) + + def _parse_external_id(data: object) -> None | Unset | UUID: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + external_id_type_0 = UUID(data) + + return external_id_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | UUID, data) + + external_id = _parse_external_id(d.pop("external_id", UNSET)) + + extra_data = d.pop("extra_data", UNSET) + measurement = cls( category=category, value=value, id=id, date=date, notes=notes, + source=source, + external_id=external_id, + extra_data=extra_data, ) measurement.additional_properties = d diff --git a/wger_api_client/models/measurement_aggregate_list_bucket.py b/wger_api_client/models/measurement_aggregate_list_bucket.py new file mode 100644 index 0000000..299de73 --- /dev/null +++ b/wger_api_client/models/measurement_aggregate_list_bucket.py @@ -0,0 +1,21 @@ +from typing import Literal + +MeasurementAggregateListBucket = Literal["auto", "day", "hour", "month", "week"] + +MEASUREMENT_AGGREGATE_LIST_BUCKET_VALUES: set[MeasurementAggregateListBucket] = { + "auto", + "day", + "hour", + "month", + "week", +} + + +def check_measurement_aggregate_list_bucket( + value: str, +) -> MeasurementAggregateListBucket: + if value in MEASUREMENT_AGGREGATE_LIST_BUCKET_VALUES: + return value + raise TypeError( + f"Unexpected value {value!r}. Expected one of {MEASUREMENT_AGGREGATE_LIST_BUCKET_VALUES!r}" + ) diff --git a/wger_api_client/models/measurement_aggregate_list_source.py b/wger_api_client/models/measurement_aggregate_list_source.py new file mode 100644 index 0000000..a58001c --- /dev/null +++ b/wger_api_client/models/measurement_aggregate_list_source.py @@ -0,0 +1,20 @@ +from typing import Literal + +MeasurementAggregateListSource = Literal["apple", "calculated", "google", "user"] + +MEASUREMENT_AGGREGATE_LIST_SOURCE_VALUES: set[MeasurementAggregateListSource] = { + "apple", + "calculated", + "google", + "user", +} + + +def check_measurement_aggregate_list_source( + value: str, +) -> MeasurementAggregateListSource: + if value in MEASUREMENT_AGGREGATE_LIST_SOURCE_VALUES: + return value + raise TypeError( + f"Unexpected value {value!r}. Expected one of {MEASUREMENT_AGGREGATE_LIST_SOURCE_VALUES!r}" + ) diff --git a/wger_api_client/models/measurement_category_list_metric_type.py b/wger_api_client/models/measurement_category_list_metric_type.py new file mode 100644 index 0000000..e5a4572 --- /dev/null +++ b/wger_api_client/models/measurement_category_list_metric_type.py @@ -0,0 +1,57 @@ +from typing import Literal + +MeasurementCategoryListMetricType = Literal[ + "blood_oxygen", + "blood_pressure", + "blood_pressure_diastolic", + "blood_pressure_systolic", + "body_fat", + "body_weight", + "custom", + "distance", + "energy", + "heart_rate", + "height", + "lean_body_mass", + "resting_heart_rate", + "sleep", + "sleep_awake", + "sleep_deep", + "sleep_light", + "sleep_rem", + "sleep_total", + "steps", +] + +MEASUREMENT_CATEGORY_LIST_METRIC_TYPE_VALUES: set[MeasurementCategoryListMetricType] = { + "blood_oxygen", + "blood_pressure", + "blood_pressure_diastolic", + "blood_pressure_systolic", + "body_fat", + "body_weight", + "custom", + "distance", + "energy", + "heart_rate", + "height", + "lean_body_mass", + "resting_heart_rate", + "sleep", + "sleep_awake", + "sleep_deep", + "sleep_light", + "sleep_rem", + "sleep_total", + "steps", +} + + +def check_measurement_category_list_metric_type( + value: str, +) -> MeasurementCategoryListMetricType: + if value in MEASUREMENT_CATEGORY_LIST_METRIC_TYPE_VALUES: + return value + raise TypeError( + f"Unexpected value {value!r}. Expected one of {MEASUREMENT_CATEGORY_LIST_METRIC_TYPE_VALUES!r}" + ) diff --git a/wger_api_client/models/measurement_list_source.py b/wger_api_client/models/measurement_list_source.py new file mode 100644 index 0000000..4764213 --- /dev/null +++ b/wger_api_client/models/measurement_list_source.py @@ -0,0 +1,18 @@ +from typing import Literal + +MeasurementListSource = Literal["apple", "calculated", "google", "user"] + +MEASUREMENT_LIST_SOURCE_VALUES: set[MeasurementListSource] = { + "apple", + "calculated", + "google", + "user", +} + + +def check_measurement_list_source(value: str) -> MeasurementListSource: + if value in MEASUREMENT_LIST_SOURCE_VALUES: + return value + raise TypeError( + f"Unexpected value {value!r}. Expected one of {MEASUREMENT_LIST_SOURCE_VALUES!r}" + ) diff --git a/wger_api_client/models/measurement_request.py b/wger_api_client/models/measurement_request.py index 3740ce7..5acf3d6 100644 --- a/wger_api_client/models/measurement_request.py +++ b/wger_api_client/models/measurement_request.py @@ -2,12 +2,13 @@ import datetime from collections.abc import Mapping -from typing import Any, Self, TypeVar +from typing import Any, Self, TypeVar, cast from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field +from ..models.source_enum import SourceEnum, check_source_enum from ..types import UNSET, Unset T = TypeVar("T", bound="MeasurementRequest") @@ -23,6 +24,12 @@ class MeasurementRequest: id (UUID | Unset): date (datetime.datetime | Unset): notes (str | Unset): + source (SourceEnum | Unset): * `user` - User + * `google` - Google + * `apple` - Apple + * `calculated` - Calculated Default: 'user'. + external_id (None | Unset | UUID): + extra_data (Any | Unset): """ category: UUID @@ -30,6 +37,9 @@ class MeasurementRequest: id: UUID | Unset = UNSET date: datetime.datetime | Unset = UNSET notes: str | Unset = UNSET + source: SourceEnum | Unset = "user" + external_id: None | Unset | UUID = UNSET + extra_data: Any | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -47,6 +57,20 @@ def to_dict(self) -> dict[str, Any]: notes = self.notes + source: str | Unset = UNSET + if not isinstance(self.source, Unset): + source = self.source + + external_id: None | str | Unset + if isinstance(self.external_id, Unset): + external_id = UNSET + elif isinstance(self.external_id, UUID): + external_id = str(self.external_id) + else: + external_id = self.external_id + + extra_data = self.extra_data + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( @@ -61,6 +85,12 @@ def to_dict(self) -> dict[str, Any]: field_dict["date"] = date if notes is not UNSET: field_dict["notes"] = notes + if source is not UNSET: + field_dict["source"] = source + if external_id is not UNSET: + field_dict["external_id"] = external_id + if extra_data is not UNSET: + field_dict["extra_data"] = extra_data return field_dict @@ -87,12 +117,41 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: notes = d.pop("notes", UNSET) + _source = d.pop("source", UNSET) + source: SourceEnum | Unset + if isinstance(_source, Unset): + source = UNSET + else: + source = check_source_enum(_source) + + def _parse_external_id(data: object) -> None | Unset | UUID: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + external_id_type_0 = UUID(data) + + return external_id_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | UUID, data) + + external_id = _parse_external_id(d.pop("external_id", UNSET)) + + extra_data = d.pop("extra_data", UNSET) + measurement_request = cls( category=category, value=value, id=id, date=date, notes=notes, + source=source, + external_id=external_id, + extra_data=extra_data, ) measurement_request.additional_properties = d diff --git a/wger_api_client/models/measurement_value_counts_list_source.py b/wger_api_client/models/measurement_value_counts_list_source.py new file mode 100644 index 0000000..923665e --- /dev/null +++ b/wger_api_client/models/measurement_value_counts_list_source.py @@ -0,0 +1,20 @@ +from typing import Literal + +MeasurementValueCountsListSource = Literal["apple", "calculated", "google", "user"] + +MEASUREMENT_VALUE_COUNTS_LIST_SOURCE_VALUES: set[MeasurementValueCountsListSource] = { + "apple", + "calculated", + "google", + "user", +} + + +def check_measurement_value_counts_list_source( + value: str, +) -> MeasurementValueCountsListSource: + if value in MEASUREMENT_VALUE_COUNTS_LIST_SOURCE_VALUES: + return value + raise TypeError( + f"Unexpected value {value!r}. Expected one of {MEASUREMENT_VALUE_COUNTS_LIST_SOURCE_VALUES!r}" + ) diff --git a/wger_api_client/models/metric_type_enum.py b/wger_api_client/models/metric_type_enum.py new file mode 100644 index 0000000..57d4de6 --- /dev/null +++ b/wger_api_client/models/metric_type_enum.py @@ -0,0 +1,55 @@ +from typing import Literal + +MetricTypeEnum = Literal[ + "blood_oxygen", + "blood_pressure", + "blood_pressure_diastolic", + "blood_pressure_systolic", + "body_fat", + "body_weight", + "custom", + "distance", + "energy", + "heart_rate", + "height", + "lean_body_mass", + "resting_heart_rate", + "sleep", + "sleep_awake", + "sleep_deep", + "sleep_light", + "sleep_rem", + "sleep_total", + "steps", +] + +METRIC_TYPE_ENUM_VALUES: set[MetricTypeEnum] = { + "blood_oxygen", + "blood_pressure", + "blood_pressure_diastolic", + "blood_pressure_systolic", + "body_fat", + "body_weight", + "custom", + "distance", + "energy", + "heart_rate", + "height", + "lean_body_mass", + "resting_heart_rate", + "sleep", + "sleep_awake", + "sleep_deep", + "sleep_light", + "sleep_rem", + "sleep_total", + "steps", +} + + +def check_metric_type_enum(value: str) -> MetricTypeEnum: + if value in METRIC_TYPE_ENUM_VALUES: + return value + raise TypeError( + f"Unexpected value {value!r}. Expected one of {METRIC_TYPE_ENUM_VALUES!r}" + ) diff --git a/wger_api_client/models/patched_category_request.py b/wger_api_client/models/patched_category_request.py index 304a71d..a08cb7f 100644 --- a/wger_api_client/models/patched_category_request.py +++ b/wger_api_client/models/patched_category_request.py @@ -1,12 +1,16 @@ from __future__ import annotations from collections.abc import Mapping -from typing import Any, Self, TypeVar +from typing import Any, Self, TypeVar, cast from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field +from ..models.blank_enum import BlankEnum, check_blank_enum +from ..models.chart_type_enum import ChartTypeEnum, check_chart_type_enum +from ..models.dynamic_type_enum import DynamicTypeEnum, check_dynamic_type_enum +from ..models.metric_type_enum import MetricTypeEnum, check_metric_type_enum from ..types import UNSET, Unset T = TypeVar("T", bound="PatchedCategoryRequest") @@ -20,11 +24,48 @@ class PatchedCategoryRequest: id (UUID | Unset): name (str | Unset): unit (str | Unset): + metric_type (MetricTypeEnum | Unset): * `custom` - Custom + * `body_weight` - Body Weight + * `body_fat` - Body Fat + * `lean_body_mass` - Lean Body Mass + * `height` - Height + * `blood_pressure` - Blood Pressure + * `blood_pressure_systolic` - Blood Pressure Systolic + * `blood_pressure_diastolic` - Blood Pressure Diastolic + * `heart_rate` - Heart Rate + * `resting_heart_rate` - Resting Heart Rate + * `blood_oxygen` - Blood Oxygen + * `steps` - Steps + * `distance` - Distance + * `energy` - Energy + * `sleep` - Sleep + * `sleep_total` - Total sleep + * `sleep_light` - Light sleep + * `sleep_deep` - Deep sleep + * `sleep_rem` - REM sleep + * `sleep_awake` - Awake + chart_type (BlankEnum | ChartTypeEnum | None | Unset): + chart_config (Any | Unset): + parent (None | Unset | UUID): + order (int | Unset): + dynamic_type (DynamicTypeEnum | Unset): * `NONE` - None + * `BMI` - BMI + * `WHTR` - Waist-to-height ratio + * `ONE_REP_MAX` - 1RM + * `ONE_RM_TOTAL` - 1RM total + dynamic_params (Any | Unset): Configuration parameters for dynamic calculations """ id: UUID | Unset = UNSET name: str | Unset = UNSET unit: str | Unset = UNSET + metric_type: MetricTypeEnum | Unset = UNSET + chart_type: BlankEnum | ChartTypeEnum | None | Unset = UNSET + chart_config: Any | Unset = UNSET + parent: None | Unset | UUID = UNSET + order: int | Unset = UNSET + dynamic_type: DynamicTypeEnum | Unset = UNSET + dynamic_params: Any | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -36,6 +77,36 @@ def to_dict(self) -> dict[str, Any]: unit = self.unit + metric_type: str | Unset = UNSET + if not isinstance(self.metric_type, Unset): + metric_type = self.metric_type + + chart_type: None | str | Unset + if isinstance(self.chart_type, Unset): + chart_type = UNSET + elif isinstance(self.chart_type, str) or isinstance(self.chart_type, str): + chart_type = self.chart_type + else: + chart_type = self.chart_type + + chart_config = self.chart_config + + parent: None | str | Unset + if isinstance(self.parent, Unset): + parent = UNSET + elif isinstance(self.parent, UUID): + parent = str(self.parent) + else: + parent = self.parent + + order = self.order + + dynamic_type: str | Unset = UNSET + if not isinstance(self.dynamic_type, Unset): + dynamic_type = self.dynamic_type + + dynamic_params = self.dynamic_params + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) @@ -45,6 +116,20 @@ def to_dict(self) -> dict[str, Any]: field_dict["name"] = name if unit is not UNSET: field_dict["unit"] = unit + if metric_type is not UNSET: + field_dict["metric_type"] = metric_type + if chart_type is not UNSET: + field_dict["chart_type"] = chart_type + if chart_config is not UNSET: + field_dict["chart_config"] = chart_config + if parent is not UNSET: + field_dict["parent"] = parent + if order is not UNSET: + field_dict["order"] = order + if dynamic_type is not UNSET: + field_dict["dynamic_type"] = dynamic_type + if dynamic_params is not UNSET: + field_dict["dynamic_params"] = dynamic_params return field_dict @@ -62,10 +147,79 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: unit = d.pop("unit", UNSET) + _metric_type = d.pop("metric_type", UNSET) + metric_type: MetricTypeEnum | Unset + if isinstance(_metric_type, Unset): + metric_type = UNSET + else: + metric_type = check_metric_type_enum(_metric_type) + + def _parse_chart_type(data: object) -> BlankEnum | ChartTypeEnum | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + chart_type_type_0 = check_chart_type_enum(data) + + return chart_type_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + try: + if not isinstance(data, str): + raise TypeError() + chart_type_type_1 = check_blank_enum(data) + + return chart_type_type_1 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(BlankEnum | ChartTypeEnum | None | Unset, data) + + chart_type = _parse_chart_type(d.pop("chart_type", UNSET)) + + chart_config = d.pop("chart_config", UNSET) + + def _parse_parent(data: object) -> None | Unset | UUID: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + parent_type_0 = UUID(data) + + return parent_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | UUID, data) + + parent = _parse_parent(d.pop("parent", UNSET)) + + order = d.pop("order", UNSET) + + _dynamic_type = d.pop("dynamic_type", UNSET) + dynamic_type: DynamicTypeEnum | Unset + if isinstance(_dynamic_type, Unset): + dynamic_type = UNSET + else: + dynamic_type = check_dynamic_type_enum(_dynamic_type) + + dynamic_params = d.pop("dynamic_params", UNSET) + patched_category_request = cls( id=id, name=name, unit=unit, + metric_type=metric_type, + chart_type=chart_type, + chart_config=chart_config, + parent=parent, + order=order, + dynamic_type=dynamic_type, + dynamic_params=dynamic_params, ) patched_category_request.additional_properties = d diff --git a/wger_api_client/models/patched_measurement_request.py b/wger_api_client/models/patched_measurement_request.py index ddedaff..0b4a125 100644 --- a/wger_api_client/models/patched_measurement_request.py +++ b/wger_api_client/models/patched_measurement_request.py @@ -2,12 +2,13 @@ import datetime from collections.abc import Mapping -from typing import Any, Self, TypeVar +from typing import Any, Self, TypeVar, cast from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field +from ..models.source_enum import SourceEnum, check_source_enum from ..types import UNSET, Unset T = TypeVar("T", bound="PatchedMeasurementRequest") @@ -23,6 +24,12 @@ class PatchedMeasurementRequest: date (datetime.datetime | Unset): value (float | Unset): notes (str | Unset): + source (SourceEnum | Unset): * `user` - User + * `google` - Google + * `apple` - Apple + * `calculated` - Calculated + external_id (None | Unset | UUID): + extra_data (Any | Unset): """ id: UUID | Unset = UNSET @@ -30,6 +37,9 @@ class PatchedMeasurementRequest: date: datetime.datetime | Unset = UNSET value: float | Unset = UNSET notes: str | Unset = UNSET + source: SourceEnum | Unset = UNSET + external_id: None | Unset | UUID = UNSET + extra_data: Any | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -49,6 +59,20 @@ def to_dict(self) -> dict[str, Any]: notes = self.notes + source: str | Unset = UNSET + if not isinstance(self.source, Unset): + source = self.source + + external_id: None | str | Unset + if isinstance(self.external_id, Unset): + external_id = UNSET + elif isinstance(self.external_id, UUID): + external_id = str(self.external_id) + else: + external_id = self.external_id + + extra_data = self.extra_data + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) @@ -62,6 +86,12 @@ def to_dict(self) -> dict[str, Any]: field_dict["value"] = value if notes is not UNSET: field_dict["notes"] = notes + if source is not UNSET: + field_dict["source"] = source + if external_id is not UNSET: + field_dict["external_id"] = external_id + if extra_data is not UNSET: + field_dict["extra_data"] = extra_data return field_dict @@ -93,12 +123,41 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: notes = d.pop("notes", UNSET) + _source = d.pop("source", UNSET) + source: SourceEnum | Unset + if isinstance(_source, Unset): + source = UNSET + else: + source = check_source_enum(_source) + + def _parse_external_id(data: object) -> None | Unset | UUID: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + external_id_type_0 = UUID(data) + + return external_id_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | UUID, data) + + external_id = _parse_external_id(d.pop("external_id", UNSET)) + + extra_data = d.pop("extra_data", UNSET) + patched_measurement_request = cls( id=id, category=category, date=date, value=value, notes=notes, + source=source, + external_id=external_id, + extra_data=extra_data, ) patched_measurement_request.additional_properties = d diff --git a/wger_api_client/models/patched_userprofile_request.py b/wger_api_client/models/patched_userprofile_request.py index c80ce9a..3f8a85b 100644 --- a/wger_api_client/models/patched_userprofile_request.py +++ b/wger_api_client/models/patched_userprofile_request.py @@ -56,6 +56,8 @@ class PatchedUserprofileRequest: weight_unit (WeightUnitEnum | Unset): * `kg` - Metric (kilogram) * `lb` - Imperial (pound) num_days_weight_reminder (int | Unset): Number of days after the last weight entry (enter 0 to deactivate) + time_zone (str | Unset): IANA timezone name, e.g. "Europe/Berlin". Empty means no client has reported one and + the instance timezone is used. """ weight_rounding: None | str | Unset = UNSET @@ -78,6 +80,7 @@ class PatchedUserprofileRequest: calories: int | None | Unset = UNSET weight_unit: WeightUnitEnum | Unset = UNSET num_days_weight_reminder: int | Unset = UNSET + time_zone: str | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -189,6 +192,8 @@ def to_dict(self) -> dict[str, Any]: num_days_weight_reminder = self.num_days_weight_reminder + time_zone = self.time_zone + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) @@ -232,6 +237,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["weight_unit"] = weight_unit if num_days_weight_reminder is not UNSET: field_dict["num_days_weight_reminder"] = num_days_weight_reminder + if time_zone is not UNSET: + field_dict["time_zone"] = time_zone return field_dict @@ -426,6 +433,8 @@ def _parse_calories(data: object) -> int | None | Unset: num_days_weight_reminder = d.pop("num_days_weight_reminder", UNSET) + time_zone = d.pop("time_zone", UNSET) + patched_userprofile_request = cls( weight_rounding=weight_rounding, repetitions_rounding=repetitions_rounding, @@ -447,6 +456,7 @@ def _parse_calories(data: object) -> int | None | Unset: calories=calories, weight_unit=weight_unit, num_days_weight_reminder=num_days_weight_reminder, + time_zone=time_zone, ) patched_userprofile_request.additional_properties = d diff --git a/wger_api_client/models/patched_weight_entry_request.py b/wger_api_client/models/patched_weight_entry_request.py index 6f57297..69d71bd 100644 --- a/wger_api_client/models/patched_weight_entry_request.py +++ b/wger_api_client/models/patched_weight_entry_request.py @@ -3,6 +3,7 @@ import datetime from collections.abc import Mapping from typing import Any, Self, TypeVar +from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -17,15 +18,21 @@ class PatchedWeightEntryRequest: """Weight serializer Attributes: + id (UUID | Unset): date (datetime.datetime | Unset): weight (str | Unset): """ + id: UUID | Unset = UNSET date: datetime.datetime | Unset = UNSET weight: str | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + id: str | Unset = UNSET + if not isinstance(self.id, Unset): + id = str(self.id) + date: str | Unset = UNSET if not isinstance(self.date, Unset): date = self.date.isoformat() @@ -35,6 +42,8 @@ def to_dict(self) -> dict[str, Any]: field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id if date is not UNSET: field_dict["date"] = date if weight is not UNSET: @@ -45,6 +54,13 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: d = dict(src_dict) + _id = d.pop("id", UNSET) + id: UUID | Unset + if isinstance(_id, Unset): + id = UNSET + else: + id = UUID(_id) + _date = d.pop("date", UNSET) date: datetime.datetime | Unset if isinstance(_date, Unset): @@ -55,6 +71,7 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: weight = d.pop("weight", UNSET) patched_weight_entry_request = cls( + id=id, date=date, weight=weight, ) diff --git a/wger_api_client/models/patched_workout_session_request.py b/wger_api_client/models/patched_workout_session_request.py index ef2d053..5c75392 100644 --- a/wger_api_client/models/patched_workout_session_request.py +++ b/wger_api_client/models/patched_workout_session_request.py @@ -22,23 +22,21 @@ class PatchedWorkoutSessionRequest: id (UUID | Unset): routine (int | None | Unset): day (int | None | Unset): - date (datetime.date | Unset): notes (None | str | Unset): Any notes you might want to save about this workout session. impression (ImpressionEnum | Unset): * `1` - Bad * `2` - Neutral * `3` - Good - time_start (None | str | Unset): - time_end (None | str | Unset): + datetime_start (datetime.datetime | Unset): + datetime_end (datetime.datetime | None | Unset): """ id: UUID | Unset = UNSET routine: int | None | Unset = UNSET day: int | None | Unset = UNSET - date: datetime.date | Unset = UNSET notes: None | str | Unset = UNSET impression: ImpressionEnum | Unset = UNSET - time_start: None | str | Unset = UNSET - time_end: None | str | Unset = UNSET + datetime_start: datetime.datetime | Unset = UNSET + datetime_end: datetime.datetime | None | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -58,10 +56,6 @@ def to_dict(self) -> dict[str, Any]: else: day = self.day - date: str | Unset = UNSET - if not isinstance(self.date, Unset): - date = self.date.isoformat() - notes: None | str | Unset if isinstance(self.notes, Unset): notes = UNSET @@ -72,17 +66,17 @@ def to_dict(self) -> dict[str, Any]: if not isinstance(self.impression, Unset): impression = self.impression - time_start: None | str | Unset - if isinstance(self.time_start, Unset): - time_start = UNSET - else: - time_start = self.time_start + datetime_start: str | Unset = UNSET + if not isinstance(self.datetime_start, Unset): + datetime_start = self.datetime_start.isoformat() - time_end: None | str | Unset - if isinstance(self.time_end, Unset): - time_end = UNSET + datetime_end: None | str | Unset + if isinstance(self.datetime_end, Unset): + datetime_end = UNSET + elif isinstance(self.datetime_end, datetime.datetime): + datetime_end = self.datetime_end.isoformat() else: - time_end = self.time_end + datetime_end = self.datetime_end field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) @@ -93,16 +87,14 @@ def to_dict(self) -> dict[str, Any]: field_dict["routine"] = routine if day is not UNSET: field_dict["day"] = day - if date is not UNSET: - field_dict["date"] = date if notes is not UNSET: field_dict["notes"] = notes if impression is not UNSET: field_dict["impression"] = impression - if time_start is not UNSET: - field_dict["time_start"] = time_start - if time_end is not UNSET: - field_dict["time_end"] = time_end + if datetime_start is not UNSET: + field_dict["datetime_start"] = datetime_start + if datetime_end is not UNSET: + field_dict["datetime_end"] = datetime_end return field_dict @@ -134,13 +126,6 @@ def _parse_day(data: object) -> int | None | Unset: day = _parse_day(d.pop("day", UNSET)) - _date = d.pop("date", UNSET) - date: datetime.date | Unset - if isinstance(_date, Unset): - date = UNSET - else: - date = datetime.date.fromisoformat(_date) - def _parse_notes(data: object) -> None | str | Unset: if data is None: return data @@ -157,33 +142,38 @@ def _parse_notes(data: object) -> None | str | Unset: else: impression = check_impression_enum(_impression) - def _parse_time_start(data: object) -> None | str | Unset: - if data is None: - return data - if isinstance(data, Unset): - return data - return cast(None | str | Unset, data) - - time_start = _parse_time_start(d.pop("time_start", UNSET)) + _datetime_start = d.pop("datetime_start", UNSET) + datetime_start: datetime.datetime | Unset + if isinstance(_datetime_start, Unset): + datetime_start = UNSET + else: + datetime_start = datetime.datetime.fromisoformat(_datetime_start) - def _parse_time_end(data: object) -> None | str | Unset: + def _parse_datetime_end(data: object) -> datetime.datetime | None | Unset: if data is None: return data if isinstance(data, Unset): return data - return cast(None | str | Unset, data) + try: + if not isinstance(data, str): + raise TypeError() + datetime_end_type_0 = datetime.datetime.fromisoformat(data) + + return datetime_end_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(datetime.datetime | None | Unset, data) - time_end = _parse_time_end(d.pop("time_end", UNSET)) + datetime_end = _parse_datetime_end(d.pop("datetime_end", UNSET)) patched_workout_session_request = cls( id=id, routine=routine, day=day, - date=date, notes=notes, impression=impression, - time_start=time_start, - time_end=time_end, + datetime_start=datetime_start, + datetime_end=datetime_end, ) patched_workout_session_request.additional_properties = d diff --git a/wger_api_client/models/source_enum.py b/wger_api_client/models/source_enum.py new file mode 100644 index 0000000..0ea97a0 --- /dev/null +++ b/wger_api_client/models/source_enum.py @@ -0,0 +1,18 @@ +from typing import Literal + +SourceEnum = Literal["apple", "calculated", "google", "user"] + +SOURCE_ENUM_VALUES: set[SourceEnum] = { + "apple", + "calculated", + "google", + "user", +} + + +def check_source_enum(value: str) -> SourceEnum: + if value in SOURCE_ENUM_VALUES: + return value + raise TypeError( + f"Unexpected value {value!r}. Expected one of {SOURCE_ENUM_VALUES!r}" + ) diff --git a/wger_api_client/models/userprofile.py b/wger_api_client/models/userprofile.py index c2bc219..5d068c6 100644 --- a/wger_api_client/models/userprofile.py +++ b/wger_api_client/models/userprofile.py @@ -64,6 +64,8 @@ class Userprofile: weight_unit (WeightUnitEnum | Unset): * `kg` - Metric (kilogram) * `lb` - Imperial (pound) num_days_weight_reminder (int | Unset): Number of days after the last weight entry (enter 0 to deactivate) + time_zone (str | Unset): IANA timezone name, e.g. "Europe/Berlin". Empty means no client has reported one and + the instance timezone is used. """ username: str @@ -94,6 +96,7 @@ class Userprofile: calories: int | None | Unset = UNSET weight_unit: WeightUnitEnum | Unset = UNSET num_days_weight_reminder: int | Unset = UNSET + time_zone: str | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -226,6 +229,8 @@ def to_dict(self) -> dict[str, Any]: num_days_weight_reminder = self.num_days_weight_reminder + time_zone = self.time_zone + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( @@ -280,6 +285,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["weight_unit"] = weight_unit if num_days_weight_reminder is not UNSET: field_dict["num_days_weight_reminder"] = num_days_weight_reminder + if time_zone is not UNSET: + field_dict["time_zone"] = time_zone return field_dict @@ -509,6 +516,8 @@ def _parse_calories(data: object) -> int | None | Unset: num_days_weight_reminder = d.pop("num_days_weight_reminder", UNSET) + time_zone = d.pop("time_zone", UNSET) + userprofile = cls( username=username, email=email, @@ -538,6 +547,7 @@ def _parse_calories(data: object) -> int | None | Unset: calories=calories, weight_unit=weight_unit, num_days_weight_reminder=num_days_weight_reminder, + time_zone=time_zone, ) userprofile.additional_properties = d diff --git a/wger_api_client/models/userprofile_request.py b/wger_api_client/models/userprofile_request.py index 6682cd1..c83b19a 100644 --- a/wger_api_client/models/userprofile_request.py +++ b/wger_api_client/models/userprofile_request.py @@ -56,6 +56,8 @@ class UserprofileRequest: weight_unit (WeightUnitEnum | Unset): * `kg` - Metric (kilogram) * `lb` - Imperial (pound) num_days_weight_reminder (int | Unset): Number of days after the last weight entry (enter 0 to deactivate) + time_zone (str | Unset): IANA timezone name, e.g. "Europe/Berlin". Empty means no client has reported one and + the instance timezone is used. """ weight_rounding: None | str | Unset = UNSET @@ -78,6 +80,7 @@ class UserprofileRequest: calories: int | None | Unset = UNSET weight_unit: WeightUnitEnum | Unset = UNSET num_days_weight_reminder: int | Unset = UNSET + time_zone: str | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -189,6 +192,8 @@ def to_dict(self) -> dict[str, Any]: num_days_weight_reminder = self.num_days_weight_reminder + time_zone = self.time_zone + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) @@ -232,6 +237,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["weight_unit"] = weight_unit if num_days_weight_reminder is not UNSET: field_dict["num_days_weight_reminder"] = num_days_weight_reminder + if time_zone is not UNSET: + field_dict["time_zone"] = time_zone return field_dict @@ -426,6 +433,8 @@ def _parse_calories(data: object) -> int | None | Unset: num_days_weight_reminder = d.pop("num_days_weight_reminder", UNSET) + time_zone = d.pop("time_zone", UNSET) + userprofile_request = cls( weight_rounding=weight_rounding, repetitions_rounding=repetitions_rounding, @@ -447,6 +456,7 @@ def _parse_calories(data: object) -> int | None | Unset: calories=calories, weight_unit=weight_unit, num_days_weight_reminder=num_days_weight_reminder, + time_zone=time_zone, ) userprofile_request.additional_properties = d diff --git a/wger_api_client/models/value_count.py b/wger_api_client/models/value_count.py new file mode 100644 index 0000000..2470a76 --- /dev/null +++ b/wger_api_client/models/value_count.py @@ -0,0 +1,103 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import Any, Self, TypeVar, cast +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ValueCount") + + +@_attrs_define +class ValueCount: + """How often one value occurred, and when it was measured last. Read-only for + the same reason as `BucketSerializer`. + + Attributes: + category (UUID): + value (str): + unit (None | str): + count (int): + newest (datetime.datetime): + """ + + category: UUID + value: str + unit: None | str + count: int + newest: datetime.datetime + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + category = str(self.category) + + value = self.value + + unit: None | str + unit = self.unit + + count = self.count + + newest = self.newest.isoformat() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "category": category, + "value": value, + "unit": unit, + "count": count, + "newest": newest, + } + ) + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + d = dict(src_dict) + category = UUID(d.pop("category")) + + value = d.pop("value") + + def _parse_unit(data: object) -> None | str: + if data is None: + return data + return cast(None | str, data) + + unit = _parse_unit(d.pop("unit")) + + count = d.pop("count") + + newest = datetime.datetime.fromisoformat(d.pop("newest")) + + value_count = cls( + category=category, + value=value, + unit=unit, + count=count, + newest=newest, + ) + + value_count.additional_properties = d + return value_count + + @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 diff --git a/wger_api_client/models/weight_entry.py b/wger_api_client/models/weight_entry.py index 88eab40..528bfea 100644 --- a/wger_api_client/models/weight_entry.py +++ b/wger_api_client/models/weight_entry.py @@ -3,10 +3,13 @@ import datetime from collections.abc import Mapping from typing import Any, Self, TypeVar +from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field +from ..types import UNSET, Unset + T = TypeVar("T", bound="WeightEntry") @@ -15,56 +18,72 @@ class WeightEntry: """Weight serializer Attributes: - id (int): - date (datetime.datetime): weight (str): user (int): + id (UUID | Unset): + date (datetime.datetime | Unset): """ - id: int - date: datetime.datetime weight: str user: int + id: UUID | Unset = UNSET + date: datetime.datetime | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - id = self.id - - date = self.date.isoformat() - weight = self.weight user = self.user + id: str | Unset = UNSET + if not isinstance(self.id, Unset): + id = str(self.id) + + date: str | Unset = UNSET + if not isinstance(self.date, Unset): + date = self.date.isoformat() + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { - "id": id, - "date": date, "weight": weight, "user": user, } ) + if id is not UNSET: + field_dict["id"] = id + if date is not UNSET: + field_dict["date"] = date return field_dict @classmethod def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: d = dict(src_dict) - id = d.pop("id") - - date = datetime.datetime.fromisoformat(d.pop("date")) - weight = d.pop("weight") user = d.pop("user") + _id = d.pop("id", UNSET) + id: UUID | Unset + if isinstance(_id, Unset): + id = UNSET + else: + id = UUID(_id) + + _date = d.pop("date", UNSET) + date: datetime.datetime | Unset + if isinstance(_date, Unset): + date = UNSET + else: + date = datetime.datetime.fromisoformat(_date) + weight_entry = cls( - id=id, - date=date, weight=weight, user=user, + id=id, + date=date, ) weight_entry.additional_properties = d diff --git a/wger_api_client/models/weight_entry_request.py b/wger_api_client/models/weight_entry_request.py index 68d4cb6..b47b45b 100644 --- a/wger_api_client/models/weight_entry_request.py +++ b/wger_api_client/models/weight_entry_request.py @@ -3,10 +3,13 @@ import datetime from collections.abc import Mapping from typing import Any, Self, TypeVar +from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field +from ..types import UNSET, Unset + T = TypeVar("T", bound="WeightEntryRequest") @@ -15,40 +18,64 @@ class WeightEntryRequest: """Weight serializer Attributes: - date (datetime.datetime): weight (str): + id (UUID | Unset): + date (datetime.datetime | Unset): """ - date: datetime.datetime weight: str + id: UUID | Unset = UNSET + date: datetime.datetime | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - date = self.date.isoformat() - weight = self.weight + id: str | Unset = UNSET + if not isinstance(self.id, Unset): + id = str(self.id) + + date: str | Unset = UNSET + if not isinstance(self.date, Unset): + date = self.date.isoformat() + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { - "date": date, "weight": weight, } ) + if id is not UNSET: + field_dict["id"] = id + if date is not UNSET: + field_dict["date"] = date return field_dict @classmethod def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: d = dict(src_dict) - date = datetime.datetime.fromisoformat(d.pop("date")) - weight = d.pop("weight") + _id = d.pop("id", UNSET) + id: UUID | Unset + if isinstance(_id, Unset): + id = UNSET + else: + id = UUID(_id) + + _date = d.pop("date", UNSET) + date: datetime.datetime | Unset + if isinstance(_date, Unset): + date = UNSET + else: + date = datetime.datetime.fromisoformat(_date) + weight_entry_request = cls( - date=date, weight=weight, + id=id, + date=date, ) weight_entry_request.additional_properties = d diff --git a/wger_api_client/models/workout_session.py b/wger_api_client/models/workout_session.py index c4eb96e..f14e186 100644 --- a/wger_api_client/models/workout_session.py +++ b/wger_api_client/models/workout_session.py @@ -22,23 +22,21 @@ class WorkoutSession: id (UUID | Unset): routine (int | None | Unset): day (int | None | Unset): - date (datetime.date | Unset): notes (None | str | Unset): Any notes you might want to save about this workout session. impression (ImpressionEnum | Unset): * `1` - Bad * `2` - Neutral * `3` - Good - time_start (None | str | Unset): - time_end (None | str | Unset): + datetime_start (datetime.datetime | Unset): + datetime_end (datetime.datetime | None | Unset): """ id: UUID | Unset = UNSET routine: int | None | Unset = UNSET day: int | None | Unset = UNSET - date: datetime.date | Unset = UNSET notes: None | str | Unset = UNSET impression: ImpressionEnum | Unset = UNSET - time_start: None | str | Unset = UNSET - time_end: None | str | Unset = UNSET + datetime_start: datetime.datetime | Unset = UNSET + datetime_end: datetime.datetime | None | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -58,10 +56,6 @@ def to_dict(self) -> dict[str, Any]: else: day = self.day - date: str | Unset = UNSET - if not isinstance(self.date, Unset): - date = self.date.isoformat() - notes: None | str | Unset if isinstance(self.notes, Unset): notes = UNSET @@ -72,17 +66,17 @@ def to_dict(self) -> dict[str, Any]: if not isinstance(self.impression, Unset): impression = self.impression - time_start: None | str | Unset - if isinstance(self.time_start, Unset): - time_start = UNSET - else: - time_start = self.time_start + datetime_start: str | Unset = UNSET + if not isinstance(self.datetime_start, Unset): + datetime_start = self.datetime_start.isoformat() - time_end: None | str | Unset - if isinstance(self.time_end, Unset): - time_end = UNSET + datetime_end: None | str | Unset + if isinstance(self.datetime_end, Unset): + datetime_end = UNSET + elif isinstance(self.datetime_end, datetime.datetime): + datetime_end = self.datetime_end.isoformat() else: - time_end = self.time_end + datetime_end = self.datetime_end field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) @@ -93,16 +87,14 @@ def to_dict(self) -> dict[str, Any]: field_dict["routine"] = routine if day is not UNSET: field_dict["day"] = day - if date is not UNSET: - field_dict["date"] = date if notes is not UNSET: field_dict["notes"] = notes if impression is not UNSET: field_dict["impression"] = impression - if time_start is not UNSET: - field_dict["time_start"] = time_start - if time_end is not UNSET: - field_dict["time_end"] = time_end + if datetime_start is not UNSET: + field_dict["datetime_start"] = datetime_start + if datetime_end is not UNSET: + field_dict["datetime_end"] = datetime_end return field_dict @@ -134,13 +126,6 @@ def _parse_day(data: object) -> int | None | Unset: day = _parse_day(d.pop("day", UNSET)) - _date = d.pop("date", UNSET) - date: datetime.date | Unset - if isinstance(_date, Unset): - date = UNSET - else: - date = datetime.date.fromisoformat(_date) - def _parse_notes(data: object) -> None | str | Unset: if data is None: return data @@ -157,33 +142,38 @@ def _parse_notes(data: object) -> None | str | Unset: else: impression = check_impression_enum(_impression) - def _parse_time_start(data: object) -> None | str | Unset: - if data is None: - return data - if isinstance(data, Unset): - return data - return cast(None | str | Unset, data) - - time_start = _parse_time_start(d.pop("time_start", UNSET)) + _datetime_start = d.pop("datetime_start", UNSET) + datetime_start: datetime.datetime | Unset + if isinstance(_datetime_start, Unset): + datetime_start = UNSET + else: + datetime_start = datetime.datetime.fromisoformat(_datetime_start) - def _parse_time_end(data: object) -> None | str | Unset: + def _parse_datetime_end(data: object) -> datetime.datetime | None | Unset: if data is None: return data if isinstance(data, Unset): return data - return cast(None | str | Unset, data) + try: + if not isinstance(data, str): + raise TypeError() + datetime_end_type_0 = datetime.datetime.fromisoformat(data) + + return datetime_end_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(datetime.datetime | None | Unset, data) - time_end = _parse_time_end(d.pop("time_end", UNSET)) + datetime_end = _parse_datetime_end(d.pop("datetime_end", UNSET)) workout_session = cls( id=id, routine=routine, day=day, - date=date, notes=notes, impression=impression, - time_start=time_start, - time_end=time_end, + datetime_start=datetime_start, + datetime_end=datetime_end, ) workout_session.additional_properties = d diff --git a/wger_api_client/models/workout_session_request.py b/wger_api_client/models/workout_session_request.py index 413122f..e2c0c85 100644 --- a/wger_api_client/models/workout_session_request.py +++ b/wger_api_client/models/workout_session_request.py @@ -22,23 +22,21 @@ class WorkoutSessionRequest: id (UUID | Unset): routine (int | None | Unset): day (int | None | Unset): - date (datetime.date | Unset): notes (None | str | Unset): Any notes you might want to save about this workout session. impression (ImpressionEnum | Unset): * `1` - Bad * `2` - Neutral * `3` - Good - time_start (None | str | Unset): - time_end (None | str | Unset): + datetime_start (datetime.datetime | Unset): + datetime_end (datetime.datetime | None | Unset): """ id: UUID | Unset = UNSET routine: int | None | Unset = UNSET day: int | None | Unset = UNSET - date: datetime.date | Unset = UNSET notes: None | str | Unset = UNSET impression: ImpressionEnum | Unset = UNSET - time_start: None | str | Unset = UNSET - time_end: None | str | Unset = UNSET + datetime_start: datetime.datetime | Unset = UNSET + datetime_end: datetime.datetime | None | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -58,10 +56,6 @@ def to_dict(self) -> dict[str, Any]: else: day = self.day - date: str | Unset = UNSET - if not isinstance(self.date, Unset): - date = self.date.isoformat() - notes: None | str | Unset if isinstance(self.notes, Unset): notes = UNSET @@ -72,17 +66,17 @@ def to_dict(self) -> dict[str, Any]: if not isinstance(self.impression, Unset): impression = self.impression - time_start: None | str | Unset - if isinstance(self.time_start, Unset): - time_start = UNSET - else: - time_start = self.time_start + datetime_start: str | Unset = UNSET + if not isinstance(self.datetime_start, Unset): + datetime_start = self.datetime_start.isoformat() - time_end: None | str | Unset - if isinstance(self.time_end, Unset): - time_end = UNSET + datetime_end: None | str | Unset + if isinstance(self.datetime_end, Unset): + datetime_end = UNSET + elif isinstance(self.datetime_end, datetime.datetime): + datetime_end = self.datetime_end.isoformat() else: - time_end = self.time_end + datetime_end = self.datetime_end field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) @@ -93,16 +87,14 @@ def to_dict(self) -> dict[str, Any]: field_dict["routine"] = routine if day is not UNSET: field_dict["day"] = day - if date is not UNSET: - field_dict["date"] = date if notes is not UNSET: field_dict["notes"] = notes if impression is not UNSET: field_dict["impression"] = impression - if time_start is not UNSET: - field_dict["time_start"] = time_start - if time_end is not UNSET: - field_dict["time_end"] = time_end + if datetime_start is not UNSET: + field_dict["datetime_start"] = datetime_start + if datetime_end is not UNSET: + field_dict["datetime_end"] = datetime_end return field_dict @@ -134,13 +126,6 @@ def _parse_day(data: object) -> int | None | Unset: day = _parse_day(d.pop("day", UNSET)) - _date = d.pop("date", UNSET) - date: datetime.date | Unset - if isinstance(_date, Unset): - date = UNSET - else: - date = datetime.date.fromisoformat(_date) - def _parse_notes(data: object) -> None | str | Unset: if data is None: return data @@ -157,33 +142,38 @@ def _parse_notes(data: object) -> None | str | Unset: else: impression = check_impression_enum(_impression) - def _parse_time_start(data: object) -> None | str | Unset: - if data is None: - return data - if isinstance(data, Unset): - return data - return cast(None | str | Unset, data) - - time_start = _parse_time_start(d.pop("time_start", UNSET)) + _datetime_start = d.pop("datetime_start", UNSET) + datetime_start: datetime.datetime | Unset + if isinstance(_datetime_start, Unset): + datetime_start = UNSET + else: + datetime_start = datetime.datetime.fromisoformat(_datetime_start) - def _parse_time_end(data: object) -> None | str | Unset: + def _parse_datetime_end(data: object) -> datetime.datetime | None | Unset: if data is None: return data if isinstance(data, Unset): return data - return cast(None | str | Unset, data) + try: + if not isinstance(data, str): + raise TypeError() + datetime_end_type_0 = datetime.datetime.fromisoformat(data) + + return datetime_end_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(datetime.datetime | None | Unset, data) - time_end = _parse_time_end(d.pop("time_end", UNSET)) + datetime_end = _parse_datetime_end(d.pop("datetime_end", UNSET)) workout_session_request = cls( id=id, routine=routine, day=day, - date=date, notes=notes, impression=impression, - time_start=time_start, - time_end=time_end, + datetime_start=datetime_start, + datetime_end=datetime_end, ) workout_session_request.additional_properties = d