# coding: utf-8

"""
    ARL Infrastructure API

    OpenAPI specification for ARL (Agentic RL) Infrastructure custom resources. This SDK provides models for WarmPool, Sandbox, and Task Kubernetes custom resources. 

    The version of the OpenAPI document: v1alpha1
    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
from typing import Any, ClassVar, Dict, List, Optional
from .models.warm_pool_spec_template_spec_containers_inner_lifecycle_post_start_http_get_http_headers_inner import WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartHttpGetHttpHeadersInner
from .models.warm_pool_spec_template_spec_containers_inner_security_context_app_armor_profile import WarmPoolSpecTemplateSpecContainersInnerSecurityContextAppArmorProfile
from .models.warm_pool_spec_template_spec_containers_inner_security_context_se_linux_options import WarmPoolSpecTemplateSpecContainersInnerSecurityContextSeLinuxOptions
from .models.warm_pool_spec_template_spec_containers_inner_security_context_windows_options import WarmPoolSpecTemplateSpecContainersInnerSecurityContextWindowsOptions
from typing import Optional, Set
from typing_extensions import Self

class WarmPoolSpecTemplateSpecSecurityContext(BaseModel):
    """
    WarmPoolSpecTemplateSpecSecurityContext
    """ # noqa: E501
    app_armor_profile: Optional[WarmPoolSpecTemplateSpecContainersInnerSecurityContextAppArmorProfile] = Field(default=None, alias="appArmorProfile")
    fs_group: Optional[StrictInt] = Field(default=None, alias="fsGroup")
    fs_group_change_policy: Optional[StrictStr] = Field(default=None, alias="fsGroupChangePolicy")
    run_as_group: Optional[StrictInt] = Field(default=None, alias="runAsGroup")
    run_as_non_root: Optional[StrictBool] = Field(default=None, alias="runAsNonRoot")
    run_as_user: Optional[StrictInt] = Field(default=None, alias="runAsUser")
    se_linux_change_policy: Optional[StrictStr] = Field(default=None, alias="seLinuxChangePolicy")
    se_linux_options: Optional[WarmPoolSpecTemplateSpecContainersInnerSecurityContextSeLinuxOptions] = Field(default=None, alias="seLinuxOptions")
    seccomp_profile: Optional[WarmPoolSpecTemplateSpecContainersInnerSecurityContextAppArmorProfile] = Field(default=None, alias="seccompProfile")
    supplemental_groups: Optional[List[StrictInt]] = Field(default=None, alias="supplementalGroups")
    supplemental_groups_policy: Optional[StrictStr] = Field(default=None, alias="supplementalGroupsPolicy")
    sysctls: Optional[List[WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartHttpGetHttpHeadersInner]] = None
    windows_options: Optional[WarmPoolSpecTemplateSpecContainersInnerSecurityContextWindowsOptions] = Field(default=None, alias="windowsOptions")
    __properties: ClassVar[List[str]] = ["appArmorProfile", "fsGroup", "fsGroupChangePolicy", "runAsGroup", "runAsNonRoot", "runAsUser", "seLinuxChangePolicy", "seLinuxOptions", "seccompProfile", "supplementalGroups", "supplementalGroupsPolicy", "sysctls", "windowsOptions"]

    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 WarmPoolSpecTemplateSpecSecurityContext 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 app_armor_profile
        if self.app_armor_profile:
            _dict['appArmorProfile'] = self.app_armor_profile.to_dict()
        # override the default output from pydantic by calling `to_dict()` of se_linux_options
        if self.se_linux_options:
            _dict['seLinuxOptions'] = self.se_linux_options.to_dict()
        # override the default output from pydantic by calling `to_dict()` of seccomp_profile
        if self.seccomp_profile:
            _dict['seccompProfile'] = self.seccomp_profile.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in sysctls (list)
        _items = []
        if self.sysctls:
            for _item_sysctls in self.sysctls:
                if _item_sysctls:
                    _items.append(_item_sysctls.to_dict())
            _dict['sysctls'] = _items
        # override the default output from pydantic by calling `to_dict()` of windows_options
        if self.windows_options:
            _dict['windowsOptions'] = self.windows_options.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "appArmorProfile": WarmPoolSpecTemplateSpecContainersInnerSecurityContextAppArmorProfile.from_dict(obj["appArmorProfile"]) if obj.get("appArmorProfile") is not None else None,
            "fsGroup": obj.get("fsGroup"),
            "fsGroupChangePolicy": obj.get("fsGroupChangePolicy"),
            "runAsGroup": obj.get("runAsGroup"),
            "runAsNonRoot": obj.get("runAsNonRoot"),
            "runAsUser": obj.get("runAsUser"),
            "seLinuxChangePolicy": obj.get("seLinuxChangePolicy"),
            "seLinuxOptions": WarmPoolSpecTemplateSpecContainersInnerSecurityContextSeLinuxOptions.from_dict(obj["seLinuxOptions"]) if obj.get("seLinuxOptions") is not None else None,
            "seccompProfile": WarmPoolSpecTemplateSpecContainersInnerSecurityContextAppArmorProfile.from_dict(obj["seccompProfile"]) if obj.get("seccompProfile") is not None else None,
            "supplementalGroups": obj.get("supplementalGroups"),
            "supplementalGroupsPolicy": obj.get("supplementalGroupsPolicy"),
            "sysctls": [WarmPoolSpecTemplateSpecContainersInnerLifecyclePostStartHttpGetHttpHeadersInner.from_dict(_item) for _item in obj["sysctls"]] if obj.get("sysctls") is not None else None,
            "windowsOptions": WarmPoolSpecTemplateSpecContainersInnerSecurityContextWindowsOptions.from_dict(obj["windowsOptions"]) if obj.get("windowsOptions") is not None else None
        })
        return _obj


