# coding: utf-8

"""
    Nuon

    API for managing nuon apps, components, and installs.

    The version of the OpenAPI document: 0.19.91
    Contact: support@nuon.co
    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, StrictBool
from typing import Any, ClassVar, Dict, List, Optional
from nuon.models.app_app import AppApp
from nuon.models.app_app_input_config import AppAppInputConfig
from nuon.models.app_app_installer_metadata import AppAppInstallerMetadata
from nuon.models.app_app_sandbox_config import AppAppSandboxConfig
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class ServiceRenderedInstaller(BaseModel):
    """
    ServiceRenderedInstaller
    """ # noqa: E501
    app: Optional[AppApp] = None
    app_inputs: Optional[AppAppInputConfig] = None
    app_sandbox: Optional[AppAppSandboxConfig] = None
    metadata: Optional[AppAppInstallerMetadata] = None
    sandbox_mode: Optional[StrictBool] = None
    __properties: ClassVar[List[str]] = ["app", "app_inputs", "app_sandbox", "metadata", "sandbox_mode"]

    model_config = {
        "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) -> Self:
        """Create an instance of ServiceRenderedInstaller 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.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of app
        if self.app:
            _dict['app'] = self.app.to_dict()
        # override the default output from pydantic by calling `to_dict()` of app_inputs
        if self.app_inputs:
            _dict['app_inputs'] = self.app_inputs.to_dict()
        # override the default output from pydantic by calling `to_dict()` of app_sandbox
        if self.app_sandbox:
            _dict['app_sandbox'] = self.app_sandbox.to_dict()
        # override the default output from pydantic by calling `to_dict()` of metadata
        if self.metadata:
            _dict['metadata'] = self.metadata.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of ServiceRenderedInstaller from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "app": AppApp.from_dict(obj.get("app")) if obj.get("app") is not None else None,
            "app_inputs": AppAppInputConfig.from_dict(obj.get("app_inputs")) if obj.get("app_inputs") is not None else None,
            "app_sandbox": AppAppSandboxConfig.from_dict(obj.get("app_sandbox")) if obj.get("app_sandbox") is not None else None,
            "metadata": AppAppInstallerMetadata.from_dict(obj.get("metadata")) if obj.get("metadata") is not None else None,
            "sandbox_mode": obj.get("sandbox_mode")
        })
        return _obj


