# coding: utf-8

"""
    Intervals.icu API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: v1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from intervals_icu_client.models.athlete_search_result import AthleteSearchResult
from intervals_icu_client.models.workout import Workout
from typing import Optional, Set
from typing_extensions import Self

class Folder(BaseModel):
    """
    Folder
    """ # noqa: E501
    athlete_id: Optional[StrictStr] = None
    id: Optional[StrictInt] = None
    type: Optional[StrictStr] = None
    name: Optional[StrictStr] = None
    description: Optional[StrictStr] = None
    children: Optional[List[Workout]] = None
    visibility: Optional[StrictStr] = None
    start_date_local: Optional[StrictStr] = None
    rollout_weeks: Optional[StrictInt] = None
    auto_rollout_day: Optional[StrictInt] = None
    read_only_workouts: Optional[StrictBool] = None
    starting_ctl: Optional[StrictInt] = None
    starting_atl: Optional[StrictInt] = None
    activity_types: Optional[List[StrictStr]] = None
    num_workouts: Optional[StrictInt] = None
    duration_weeks: Optional[StrictInt] = None
    hours_per_week_min: Optional[StrictInt] = None
    hours_per_week_max: Optional[StrictInt] = None
    workout_targets: Optional[List[StrictStr]] = None
    blurb: Optional[StrictStr] = None
    can_edit: Optional[StrictBool] = Field(default=None, alias="canEdit")
    shared_with_count: Optional[StrictInt] = Field(default=None, alias="sharedWithCount")
    share_token: Optional[StrictStr] = Field(default=None, alias="shareToken")
    owner: Optional[AthleteSearchResult] = None
    __properties: ClassVar[List[str]] = ["athlete_id", "id", "type", "name", "description", "children", "visibility", "start_date_local", "rollout_weeks", "auto_rollout_day", "read_only_workouts", "starting_ctl", "starting_atl", "activity_types", "num_workouts", "duration_weeks", "hours_per_week_min", "hours_per_week_max", "workout_targets", "blurb", "canEdit", "sharedWithCount", "shareToken", "owner"]

    @field_validator('type')
    def type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['FOLDER', 'PLAN']):
            raise ValueError("must be one of enum values ('FOLDER', 'PLAN')")
        return value

    @field_validator('visibility')
    def visibility_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['PRIVATE', 'PUBLIC']):
            raise ValueError("must be one of enum values ('PRIVATE', 'PUBLIC')")
        return value

    @field_validator('activity_types')
    def activity_types_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        for i in value:
            if i not in set(['Ride', 'Run', 'Swim', 'WeightTraining', 'Hike', 'Walk', 'AlpineSki', 'BackcountrySki', 'Badminton', 'Canoeing', 'Crossfit', 'EBikeRide', 'EMountainBikeRide', 'Elliptical', 'Golf', 'GravelRide', 'TrackRide', 'Handcycle', 'HighIntensityIntervalTraining', 'Hockey', 'IceSkate', 'InlineSkate', 'Kayaking', 'Kitesurf', 'MountainBikeRide', 'NordicSki', 'OpenWaterSwim', 'Padel', 'Pilates', 'Pickleball', 'Racquetball', 'Rugby', 'RockClimbing', 'RollerSki', 'Rowing', 'Sail', 'Skateboard', 'Snowboard', 'Snowshoe', 'Soccer', 'Squash', 'StairStepper', 'StandUpPaddling', 'Surfing', 'TableTennis', 'Tennis', 'TrailRun', 'Transition', 'Velomobile', 'VirtualRide', 'VirtualRow', 'VirtualRun', 'VirtualSki', 'WaterSport', 'Wheelchair', 'Windsurf', 'Workout', 'Yoga', 'Other']):
                raise ValueError("each list item must be one of ('Ride', 'Run', 'Swim', 'WeightTraining', 'Hike', 'Walk', 'AlpineSki', 'BackcountrySki', 'Badminton', 'Canoeing', 'Crossfit', 'EBikeRide', 'EMountainBikeRide', 'Elliptical', 'Golf', 'GravelRide', 'TrackRide', 'Handcycle', 'HighIntensityIntervalTraining', 'Hockey', 'IceSkate', 'InlineSkate', 'Kayaking', 'Kitesurf', 'MountainBikeRide', 'NordicSki', 'OpenWaterSwim', 'Padel', 'Pilates', 'Pickleball', 'Racquetball', 'Rugby', 'RockClimbing', 'RollerSki', 'Rowing', 'Sail', 'Skateboard', 'Snowboard', 'Snowshoe', 'Soccer', 'Squash', 'StairStepper', 'StandUpPaddling', 'Surfing', 'TableTennis', 'Tennis', 'TrailRun', 'Transition', 'Velomobile', 'VirtualRide', 'VirtualRow', 'VirtualRun', 'VirtualSki', 'WaterSport', 'Wheelchair', 'Windsurf', 'Workout', 'Yoga', 'Other')")
        return value

    @field_validator('workout_targets')
    def workout_targets_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        for i in value:
            if i not in set(['AUTO', 'POWER', 'HR', 'PACE']):
                raise ValueError("each list item must be one of ('AUTO', 'POWER', 'HR', 'PACE')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of Folder from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in children (list)
        _items = []
        if self.children:
            for _item_children in self.children:
                if _item_children:
                    _items.append(_item_children.to_dict())
            _dict['children'] = _items
        # override the default output from pydantic by calling `to_dict()` of owner
        if self.owner:
            _dict['owner'] = self.owner.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Folder from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "athlete_id": obj.get("athlete_id"),
            "id": obj.get("id"),
            "type": obj.get("type"),
            "name": obj.get("name"),
            "description": obj.get("description"),
            "children": [Workout.from_dict(_item) for _item in obj["children"]] if obj.get("children") is not None else None,
            "visibility": obj.get("visibility"),
            "start_date_local": obj.get("start_date_local"),
            "rollout_weeks": obj.get("rollout_weeks"),
            "auto_rollout_day": obj.get("auto_rollout_day"),
            "read_only_workouts": obj.get("read_only_workouts"),
            "starting_ctl": obj.get("starting_ctl"),
            "starting_atl": obj.get("starting_atl"),
            "activity_types": obj.get("activity_types"),
            "num_workouts": obj.get("num_workouts"),
            "duration_weeks": obj.get("duration_weeks"),
            "hours_per_week_min": obj.get("hours_per_week_min"),
            "hours_per_week_max": obj.get("hours_per_week_max"),
            "workout_targets": obj.get("workout_targets"),
            "blurb": obj.get("blurb"),
            "canEdit": obj.get("canEdit"),
            "sharedWithCount": obj.get("sharedWithCount"),
            "shareToken": obj.get("shareToken"),
            "owner": AthleteSearchResult.from_dict(obj["owner"]) if obj.get("owner") is not None else None
        })
        return _obj


