# coding: utf-8

"""
    Freestyle Sandboxes

     Freestyle Sandboxes lets you deploy your users or AIs code. **Get your API Key at [admin.freestyle.sh](https://admin.freestyle.sh)**  They are broken up into core 5 categories: [Web](#tag/web), [Execute](#tag/execute), [Cloudstate](#tag/cloudstate), [Git](#tag/git), and [Domains](#tag/domains).  [Web](#tag/web): Send us the code for the website, we'll provision the certificates and get it hosted  [Execute](#tag/execute): Send us a function, we'll run it and send you the output  [Cloudstate](#tag/cloudstate): Our Opensource JavaScript Runtime used for cloud functions with persistent state  [Domains](#tag/domains): Manage your domains, including verification and listing  [Git](#tag/git): Manage your git repositories 

    The version of the OpenAPI document: 0.1.0
    Contact: ben@freestyle.sh
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class DevServerRequest(BaseModel):
    """
    DevServerRequest
    """ # noqa: E501
    dev_command: Optional[StrictStr] = Field(default=None, alias="devCommand")
    pre_dev_command_once: Optional[StrictStr] = Field(default=None, alias="preDevCommandOnce")
    base_id: Optional[StrictStr] = Field(default=None, alias="baseId")
    env_vars: Optional[Dict[str, StrictStr]] = Field(default=None, alias="envVars")
    repo_id: Optional[StrictStr] = Field(default=None, alias="repoId")
    compute_class: Optional[StrictStr] = Field(default='high', alias="computeClass")
    timeout: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, description="Timeout in seconds")
    domain: Optional[StrictStr] = None
    repo: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["devCommand", "preDevCommandOnce", "baseId", "envVars", "repoId", "computeClass", "timeout", "domain", "repo"]

    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 DevServerRequest 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,
        )
        # set to None if dev_command (nullable) is None
        # and model_fields_set contains the field
        if self.dev_command is None and "dev_command" in self.model_fields_set:
            _dict['devCommand'] = None

        # set to None if pre_dev_command_once (nullable) is None
        # and model_fields_set contains the field
        if self.pre_dev_command_once is None and "pre_dev_command_once" in self.model_fields_set:
            _dict['preDevCommandOnce'] = None

        # set to None if base_id (nullable) is None
        # and model_fields_set contains the field
        if self.base_id is None and "base_id" in self.model_fields_set:
            _dict['baseId'] = None

        # set to None if repo_id (nullable) is None
        # and model_fields_set contains the field
        if self.repo_id is None and "repo_id" in self.model_fields_set:
            _dict['repoId'] = None

        # set to None if compute_class (nullable) is None
        # and model_fields_set contains the field
        if self.compute_class is None and "compute_class" in self.model_fields_set:
            _dict['computeClass'] = None

        # set to None if timeout (nullable) is None
        # and model_fields_set contains the field
        if self.timeout is None and "timeout" in self.model_fields_set:
            _dict['timeout'] = None

        # set to None if domain (nullable) is None
        # and model_fields_set contains the field
        if self.domain is None and "domain" in self.model_fields_set:
            _dict['domain'] = None

        # set to None if repo (nullable) is None
        # and model_fields_set contains the field
        if self.repo is None and "repo" in self.model_fields_set:
            _dict['repo'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "devCommand": obj.get("devCommand"),
            "preDevCommandOnce": obj.get("preDevCommandOnce"),
            "baseId": obj.get("baseId"),
            "envVars": obj.get("envVars"),
            "repoId": obj.get("repoId"),
            "computeClass": obj.get("computeClass") if obj.get("computeClass") is not None else 'high',
            "timeout": obj.get("timeout"),
            "domain": obj.get("domain"),
            "repo": obj.get("repo")
        })
        return _obj


