# coding: utf-8

"""
    Daytona

    Daytona AI platform API Docs

    The version of the OpenAPI document: 1.0
    Contact: support@daytona.com
    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, StrictFloat, StrictInt
from typing import Any, ClassVar, Dict, List, Optional, Union
from pydantic import TypeAdapter
from typing import Optional, Set
from typing_extensions import Self

_JSON_ADAPTER = TypeAdapter(Dict[str, Any])

class UpdateOrganizationQuota(BaseModel):
    """
    UpdateOrganizationQuota
    """ # noqa: E501
    max_cpu_per_sandbox: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="maxCpuPerSandbox")
    max_memory_per_sandbox: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="maxMemoryPerSandbox")
    max_disk_per_sandbox: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="maxDiskPerSandbox")
    snapshot_quota: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="snapshotQuota")
    max_snapshot_size: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="maxSnapshotSize")
    volume_quota: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="volumeQuota")
    authenticated_rate_limit: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="authenticatedRateLimit")
    sandbox_create_rate_limit: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="sandboxCreateRateLimit")
    sandbox_lifecycle_rate_limit: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="sandboxLifecycleRateLimit")
    authenticated_rate_limit_ttl_seconds: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="authenticatedRateLimitTtlSeconds")
    sandbox_create_rate_limit_ttl_seconds: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="sandboxCreateRateLimitTtlSeconds")
    sandbox_lifecycle_rate_limit_ttl_seconds: Optional[Union[StrictFloat, StrictInt]] = Field(serialization_alias="sandboxLifecycleRateLimitTtlSeconds")
    snapshot_deactivation_timeout_minutes: Optional[Union[StrictFloat, StrictInt]] = Field(description="Time in minutes before an unused snapshot is deactivated", serialization_alias="snapshotDeactivationTimeoutMinutes")
    additional_properties: Dict[str, Any] = {}
    __properties: ClassVar[List[str]] = ["maxCpuPerSandbox", "maxMemoryPerSandbox", "maxDiskPerSandbox", "snapshotQuota", "maxSnapshotSize", "volumeQuota", "authenticatedRateLimit", "sandboxCreateRateLimit", "sandboxLifecycleRateLimit", "authenticatedRateLimitTtlSeconds", "sandboxCreateRateLimitTtlSeconds", "sandboxLifecycleRateLimitTtlSeconds", "snapshotDeactivationTimeoutMinutes"]

    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"""
        return _JSON_ADAPTER.dump_json(self.to_dict()).decode()

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of UpdateOrganizationQuota 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.
        * Fields in `self.additional_properties` are added to the output dict.
        """
        excluded_fields: Set[str] = set([
            "additional_properties",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "max_cpu_per_sandbox": obj.get("maxCpuPerSandbox"),
            "max_memory_per_sandbox": obj.get("maxMemoryPerSandbox"),
            "max_disk_per_sandbox": obj.get("maxDiskPerSandbox"),
            "snapshot_quota": obj.get("snapshotQuota"),
            "max_snapshot_size": obj.get("maxSnapshotSize"),
            "volume_quota": obj.get("volumeQuota"),
            "authenticated_rate_limit": obj.get("authenticatedRateLimit"),
            "sandbox_create_rate_limit": obj.get("sandboxCreateRateLimit"),
            "sandbox_lifecycle_rate_limit": obj.get("sandboxLifecycleRateLimit"),
            "authenticated_rate_limit_ttl_seconds": obj.get("authenticatedRateLimitTtlSeconds"),
            "sandbox_create_rate_limit_ttl_seconds": obj.get("sandboxCreateRateLimitTtlSeconds"),
            "sandbox_lifecycle_rate_limit_ttl_seconds": obj.get("sandboxLifecycleRateLimitTtlSeconds"),
            "snapshot_deactivation_timeout_minutes": obj.get("snapshotDeactivationTimeoutMinutes")
        })
        # store additional fields in additional_properties
        for _key in obj.keys():
            if _key not in cls.__properties:
                _obj.additional_properties[_key] = obj.get(_key)

        return _obj


